turbot/azure_insights

Query: compute_virtual_machine_scale_set_log_analytics_agent

Usage

powerpipe query azure_insights.query.compute_virtual_machine_scale_set_log_analytics_agent

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
'Log Analytics Agent' as label,
case when b.vm_id is not null
then 'Installed' else 'Not Installed' end as value,
case when b.vm_id is not null then 'ok' else 'alert' end as type
from
azure_compute_virtual_machine_scale_set as a
left join agent_installed_vm_scale_set as b on lower(a.id) = lower(b.vm_id)
where
lower(id) = $1
and subscription_id = split_part($1, '/', 3);

Dashboards

The query is used in the dashboards: