turbot/azure_insights

Query: compute_virtual_machine_scale_set_log_analytics_agent_installed_count

Usage

powerpipe query azure_insights.query.compute_virtual_machine_scale_set_log_analytics_agent_installed_count

SQL

with agent_installed_vm_scale_set as (
select
distinct a.id as vm_id
from
azure_compute_virtual_machine_scale_set as a,
jsonb_array_elements(extensions) as b
where
b ->> 'Publisher' = 'Microsoft.EnterpriseCloud.Monitoring'
and b ->> 'ExtensionType' = any(
ARRAY [ 'MicrosoftMonitoringAgent',
'OmsAgentForLinux' ]
)
and b ->> 'ProvisioningState' = 'Succeeded'
and b -> 'Settings' ->> 'workspaceId' is not null
)
select
count(*) as value,
'Log Analytics Agent Installed' as label,
case
count(*)
when 0 then 'alert'
else 'ok'
end as type
from
azure_compute_virtual_machine_scale_set as a
left join agent_installed_vm_scale_set as b on a.id = b.vm_id
where
b.vm_id is not null;

Dashboards

The query is used in the dashboards: