Sampel kueri Azure Resource Graph untuk Azure Service Health

Halaman ini berisi kumpulan sampel kueri Azure Resource Graph untuk Azure Service Health. Untuk mengetahui daftar lengkap sampel Azure Resource Graph, lihat Sampel Resource Graph berdasarkan kategori dan Sampel Resource Graph berdasarkan Tabel.

Azure Service Health

Dampak langganan kejadian Service Health aktif

Menghasilkan semua kejadian Service Health aktif - termasuk masalah layanan, pemeliharaan terencana, saran kesehatan, dan saran keamanan – yang dikelompokkan berdasarkan tipe kejadian dan termasuk jumlah langganan yang terdampak.

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"

Semua kejadian saran kesehatan aktif

Menghasilkan semua aktivitas Service Health saran kesehatan aktif di seluruh langganan yang dapat diakses pengguna.

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()"

Semua kejadian pemeliharaan terencana aktif

Menghasilkan semua kejadian Service Health pemeliharaan terencana aktif di seluruh langganan yang dapat diakses pengguna.

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()"

Semua kejadian Service Health aktif

Menghasilkan semua kejadian Service Health aktif di seluruh langganan yang dapat diakses pengguna termasuk masalah layanan, pemeliharaan terencana, saran kesehatan, dan saran keamanan.

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')"

Semua kejadian masalah layanan aktif

Menghasilkan semua kejadian masalah layanan (ketidaktersediaan) Service Health di seluruh langganan yang dapat diakses pengguna.

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'"

Sumber daya terdampak yang dikonfirmasi

Mengembalikan semua sumber daya yang terkena dampak untuk semua peristiwa Service Health masalah layanan (pemadaman) di semua langganan yang dapat diakses pengguna.

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"

Sumber daya terdampak yang dikonfirmasi dengan detail selengkapnya

Mengembalikan semua sumber daya yang terkena dampak untuk semua peristiwa Service Health masalah layanan (pemadaman) di semua langganan yang dapat diakses pengguna. Kueri ini juga menyediakan detail selengkapnya dari resources tabel.

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"

Kondisi sumber daya

Jumlah mesin virtual berdasarkan status ketersediaan dan Id Langganan

Mengembalikan jumlah mesin virtual (jenis Microsoft.Compute/virtualMachines) yang diagregasi oleh status ketersediaan di setiap langganan Anda.

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)"

Daftar mesin virtual dan status ketersediaan terkait menurut Id Sumber Daya

Mengembalikan daftar terbaru mesin virtual (jenis Microsoft.Compute/virtualMachines) yang diagregasi oleh status ketersediaan. Kueri juga menyediakan Id Sumber Daya terkait berdasarkan properties.targetResourceId, untuk penelusuran kesalahan dan mitigasi yang mudah. Status ketersediaan dapat berada di salah satu dari empat nilai: Tersedia, Tidak Tersedia, Diturunkan, dan Tidak Dikenal. Untuk detail lebih lanjut tentang apa maksud masing-masing status ketersediaan, silakan lihat Gambaran umum 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)"

Daftar mesin virtual berdasarkan status ketersediaan dan status daya dengan Id Sumber Daya dan Grup sumber daya

Mengembalikan daftar mesin virtual (jenis Microsoft.Compute/virtualMachines) yang diagregasi pada status daya dan status ketersediaan mereka untuk memberikan status kesehatan yang kohesif untuk mesin virtual Anda. Kueri ini juga memberikan rincian tentang grup sumber daya dan Id sumber daya yang terkait dengan setiap entri untuk visibilitas terperinci ke dalam sumber daya Anda.

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'"

Daftar mesin virtual yang tidak Tersedia berdasarkan Id Sumber daya

Mengembalikan daftar terbaru mesin virtual (jenis Microsoft.Compute/virtualMachines) yang diagregasi oleh status ketersediaannya. Daftar yang terisi hanya menyoroti mesin virtual yang status ketersediaannya tidak "Tersedia" untuk memastikan Anda mengetahui semua status mesin virtual Anda. Ketika semua mesin virtual Anda Tersedia, Anda dapat berharap untuk tidak mendapatkan hasil.

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)"

Langkah berikutnya