このページは、Azure Service Health、Resource Health、および影響を受けたリソースに対する Azure Resource Graph サンプル クエリのコレクションです。
注
各クエリの後、一般的に 5 分以内に更新された結果が表示されます。
概要
このページは、Azure Resource Graph を介して Kusto クエリ言語 (KQL) を使用して、Azure サービスとリソースの正常性を監視および理解するのに役立ちます。
これには、Azure Service Health、Resource Health、影響を受けたリソース専用のサンプル クエリが含まれています。
サービスヘルスのサンプルクエリ
サブスクリプション別の Active Service Health イベント
このクエリでは、すべてのアクティブなサービス正常性イベント (サービスの問題、計画メンテナンス、正常性アドバイザリ、セキュリティ アドバイザリなど) がイベントの種類別にグループ化され、影響を受けたサービスの数が含まれます。
たとえば、影響を受けるサブスクリプションの数を示すカウントを含む各イベントの種類を示します。
注
このイベント サブスクリプションには、新しい問題は含まれません。 詳細については、 このページを開きます。
ServiceHealthResources
| where type =~ 'Microsoft.ResourceHealth/events'
| extend eventType = tostring(properties.EventType), status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = properties.ImpactMitigationTime
| where eventType == 'ServiceIssue' and status == 'Active'
| summarize count(subscriptionId) by name
az graph query -q "ServiceHealthResources | where type =~ 'Microsoft.ResourceHealth/events' | extend eventType = tostring(properties.EventType), status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = properties.ImpactMitigationTime | where eventType == 'ServiceIssue' and status == 'Active' | summarize count(subscriptionId) by name"
すべてのアクティブな正常性アドバイザリ イベント
このクエリでは、アクセスできるすべてのサブスクリプションにおける Service Health からの、すべてのアクティブな正常性アドバイザリ イベントが一覧表示されます。
ServiceHealthResources
| where type =~ 'Microsoft.ResourceHealth/events'
| extend eventType = properties.EventType, status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = todatetime(tolong(properties.ImpactMitigationTime))
| where eventType == 'HealthAdvisory' and impactMitigationTime > now()
az graph query -q "ServiceHealthResources | where type =~ 'Microsoft.ResourceHealth/events' | extend eventType = properties.EventType, status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = todatetime(tolong(properties.ImpactMitigationTime)) | where eventType == 'HealthAdvisory' and impactMitigationTime > now()"
今後予定されているすべてのサービス提供終了イベント
このクエリでは、すべてのサブスクリプションにおける提供終了に関する今後の Service Health イベントがすべて返されます。
ServiceHealthResources
| where type =~ 'Microsoft.ResourceHealth/events'
| extend eventType = properties.EventType, status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = todatetime(tolong(properties.ImpactMitigationTime))
| where eventType == 'PlannedMaintenance' and impactMitigationTime > now()
where type =~ 'Microsoft.ResourceHealth/events'
| extend eventType = properties.EventType, eventSubType = properties.EventSubType
| where eventType == "HealthAdvisory" and eventSubType == "Retirement"
|extend status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = todatetime(tolong(properties.ImpactStartTime)), impactMitigationTime = todatetime(tolong(properties.ImpactMitigationTime)), impact = properties.Impact
| where impactMitigationTime > datetime(now)
|project trackingId, subscriptionId, status, eventType, eventSubType, summary, description, priority, impactStartTime, impactMitigationTime, impact
すべてのアクティブな計画メンテナンス イベント
このクエリは、アクセス権があるすべてのサブスクリプションにおける、アクティブな計画メンテナンスのサービス健全性イベント一覧を取得して返します。
ServiceHealthResources
| where type =~ 'Microsoft.ResourceHealth/events'
| extend eventType = properties.EventType, status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = todatetime(tolong(properties.ImpactMitigationTime))
| where eventType == 'PlannedMaintenance' and impactMitigationTime > now()
az graph query -q "ServiceHealthResources | where type =~ 'Microsoft.ResourceHealth/events' | extend eventType = properties.EventType, status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = todatetime(tolong(properties.ImpactMitigationTime)) | where eventType == 'PlannedMaintenance' and impactMitigationTime > now()"
すべてのアクティブな Service Health イベント
このクエリを使用して、すべてのサブスクリプションのサービスの問題、計画メンテナンス、正常性アドバイザリ、セキュリティ アドバイザリなど、すべてのアクティブなサービス正常性イベントを一覧表示します。
ServiceHealthResources
| where type =~ 'Microsoft.ResourceHealth/events'
| extend eventType = properties.EventType, status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = properties.ImpactMitigationTime
| where (eventType in ('HealthAdvisory', 'SecurityAdvisory', 'PlannedMaintenance') and impactMitigationTime > now()) or (eventType == 'ServiceIssue' and status == 'Active')
az graph query -q "ServiceHealthResources | where type =~ 'Microsoft.ResourceHealth/events' | extend eventType = properties.EventType, status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = properties.ImpactMitigationTime | where (eventType in ('HealthAdvisory', 'SecurityAdvisory', 'PlannedMaintenance') and impactMitigationTime > now()) or (eventType == 'ServiceIssue' and status == 'Active')"
すべてのアクティブなサービス問題イベント
このクエリでは、すべてのサブスクリプションのすべてのアクティブなサービスの問題 (停止) と Service Health イベントを検索して一覧表示します。
ServiceHealthResources
| where type =~ 'Microsoft.ResourceHealth/events'
| extend eventType = properties.EventType, status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = properties.ImpactMitigationTime
| where eventType == 'ServiceIssue' and status == 'Active'
az graph query -q "ServiceHealthResources | where type =~ 'Microsoft.ResourceHealth/events' | extend eventType = properties.EventType, status = properties.Status, description = properties.Title, trackingId = properties.TrackingId, summary = properties.Summary, priority = properties.Priority, impactStartTime = properties.ImpactStartTime, impactMitigationTime = properties.ImpactMitigationTime | where eventType == 'ServiceIssue' and status == 'Active'"
影響を受けたリソースのサンプル クエリ
影響を受けたリソースを確認済み
このクエリは、アクセスするすべてのサブスクリプションで、サービスの問題 (停止) と Service Health イベントの影響を受けるすべてのリソースの一覧を検索して返します。
ServiceHealthResources
| where type == "microsoft.resourcehealth/events/impactedresources"
| extend TrackingId = split(split(id, "/events/", 1)[0], "/impactedResources", 0)[0]
| extend p = parse_json(properties)
| project subscriptionId, TrackingId, resourceName= p.resourceName, resourceGroup=p.resourceGroup, resourceType=p.targetResourceType, details = p, id
az graph query -q "ServiceHealthResources | where type == 'microsoft.resourcehealth/events/impactedresources' | extend TrackingId = split(split(id, '/events/', 1)[0], '/impactedResources', 0)[0] | extend p = parse_json(properties) | project subscriptionId, TrackingId, resourceName= p.resourceName, resourceGroup=p.resourceGroup, resourceType=p.targetResourceType, details = p, id"
詳細情報とともに、影響を受けたリソースを確認しました。
このクエリは、アクセス権を持つすべてのサブスクリプションで、サービス正常性の問題 (停止など) の影響を受けるすべてのリソースを取得します。 また、 resources
テーブルの詳細も含まれています。
servicehealthresources
| where type == "microsoft.resourcehealth/events/impactedresources"
| extend TrackingId = split(split(id, "/events/", 1)[0], "/impactedResources", 0)[0]
| extend p = parse_json(properties)
| project subscriptionId, TrackingId, targetResourceId= tostring(p.targetResourceId), details = p
| join kind=inner (
resources
)
on $left.targetResourceId == $right.id
az graph query -q "ServiceHealthResources | where type == 'microsoft.resourcehealth/events/impactedresources' | extend TrackingId = split(split(id, '/events/', 1)[0], '/impactedResources', 0)[0] | extend p = parse_json(properties) | project subscriptionId, TrackingId, targetResourceId = tostring(p.targetResourceId), details = p | join kind=inner (resources) on $left.targetResourceId == $right.id"
Resource Health サンプル クエリ
可用性とサブスクリプション ID の状態別の仮想マシンの数
このクエリでは、各可用性状態にある仮想マシン (Microsoft.Compute/virtualMachines
) の数が、各サブスクリプションごとにグループ化されて表示されます。
HealthResources
| where type =~ 'microsoft.resourcehealth/availabilitystatuses'
| summarize count() by subscriptionId, AvailabilityState = tostring(properties.availabilityState)
az graph query -q "HealthResources | where type =~ 'microsoft.resourcehealth/availabilitystatuses' | summarize count() by subscriptionId, AvailabilityState = tostring(properties.availabilityState)"
リソース ID による仮想マシンおよび関連する可用性ステータス一覧
このクエリでは、仮想マシン (VM) (Microsoft.Compute/virtualMachines
) の最新の一覧を可用性の状態別にグループ化して一覧表示します。 このクエリには、デバッグとトラブルシューティングに役立つ各 VM のリソース ID (properties.targetResourceId
) も含まれています。
可用性の状態には、使用可能、使用不可、低下、不明の 4 つの値のいずれかを指定できます。
各状態の意味の詳細については、「 Azure Resource Health の概要」を参照してください。
HealthResources
| where type =~ 'microsoft.resourcehealth/availabilitystatuses'
| summarize by ResourceId = tolower(tostring(properties.targetResourceId)), AvailabilityState = tostring(properties.availabilityState)
az graph query -q "HealthResources | where type =~ 'microsoft.resourcehealth/availabilitystatuses' | summarize by ResourceId = tolower(tostring(properties.targetResourceId)), AvailabilityState = tostring(properties.availabilityState)"
リソース ID とリソース グループを使用した可用性と電源の状態別の仮想マシンの一覧
このクエリでは、仮想マシン (Microsoft.Compute/virtualMachines
) の一覧を取得し、その電源状態と可用性状態の両方を集計することで、その正常性を集計します。
また、このクエリでは、各エントリに関連付けられているリソース グループとリソース ID に関する詳細も提供され、リソースを詳しく確認することもできます。
Resources
| where type =~ 'microsoft.compute/virtualmachines'
| project resourceGroup, Id = tolower(id), PowerState = tostring( properties.extended.instanceView.powerState.code)
| join kind=leftouter (
HealthResources
| where type =~ 'microsoft.resourcehealth/availabilitystatuses'
| where tostring(properties.targetResourceType) =~ 'microsoft.compute/virtualmachines'
| project targetResourceId = tolower(tostring(properties.targetResourceId)), AvailabilityState = tostring(properties.availabilityState))
on $left.Id == $right.targetResourceId
| project-away targetResourceId
| where PowerState != 'PowerState/deallocated'
az graph query -q "Resources | where type =~ 'microsoft.compute/virtualmachines' | project resourceGroup, Id = tolower(id), PowerState = tostring( properties.extended.instanceView.powerState.code) | join kind=leftouter ( HealthResources | where type =~ 'microsoft.resourcehealth/availabilitystatuses' | where tostring(properties.targetResourceType) =~ 'microsoft.compute/virtualmachines' | project targetResourceId = tolower(tostring(properties.targetResourceId)), AvailabilityState = tostring(properties.availabilityState)) on \$left.Id == \$right.targetResourceId | project-away targetResourceId | where PowerState != 'PowerState/deallocated'"
リソース ID で使用できない仮想マシンの一覧
このクエリでは、最新の仮想マシン (VM) (Microsoft.Compute/virtualMachines
) が一覧表示されます。この仮想マシンは 使用可能 な状態ではなく、可用性の状態によってグループ化されます。
また、トラブルシューティングに役立つ各 VM のリソース ID (properties.targetResourceId から) も含まれます。
すべての仮想マシンが 使用可能な状態の場合、クエリは結果を返しません。
HealthResources
| where type =~ 'microsoft.resourcehealth/availabilitystatuses'
| where tostring(properties.availabilityState) != 'Available'
| summarize by ResourceId = tolower(tostring(properties.targetResourceId)), AvailabilityState = tostring(properties.availabilityState)
az graph query -q "HealthResources | where type =~ 'microsoft.resourcehealth/availabilitystatuses' | where tostring(properties.availabilityState) != 'Available' | summarize by ResourceId = tolower(tostring(properties.targetResourceId)), AvailabilityState = tostring(properties.availabilityState)"