この記事では、オペレーション データベースから監視データを照会し、Azure Managed Grafana にダッシュボードを作成する方法について説明します。
Azure Monitor SCOM マネージド インスタンスにリンクされている Azure Managed Grafana から、SQL クエリを使用して、Azure Monitor SCOM マネージド インスタンスに格納されているオペレーション データベースから監視対象データを取得できます。
前提条件
Azure Managed Grafana ポータルから監視データを照会する前に、SCOM マネージド インスタンスが Azure Managed Grafana にリンクされていることを確認します。 詳細については、「Azure Managed Grafana 上のダッシュボード」をご覧ください。
Azure/SCOM マネージド インスタンス/オペレーション ダッシュボードですぐに使用できるダッシュボードはほとんどありません。これは、Azure Managed Grafana インスタンス上で要件に応じてインポート、編集できます。
Azure Managed Grafana でダッシュボードを作成する
ダッシュボードを作成するには、次の手順に従います。
- Grafana に移動し、[視覚化の追加] を選択します。 使用可能なオプションに基づいて視覚化の種類を選択できます。
- [パネル オプション] で、[タイトル] と [説明] を入力します。
- [クエリ] で [コード] を選択し、クエリを入力します。
- [クエリの実行] を選択します。
サンプル クエリ
SCOM Managed Instance で Azure Managed Grafana の使用を開始するために役立つサンプル クエリとダッシュボードを次に示します。
- ワークロードの正常性状態
- ワークロードの正常性とそれらに対する新しいアラートの数
- ワークロード上の上位のイベント
- ワークロードからの上位アラート
- ワークロード カウンターのパフォーマンス データ クエリ
次のクエリは、特定のワークロード/監視オブジェクトから正常性、アラート、上位イベントを構築するのに役立ちます。
Note
- <管理パック名のプレフィックス>を実際の管理パック名に置き換えます (たとえば、SQL ワークロードの Microsoft.SQL%)。
- <監視オブジェクトの種類>をコンポーネント クラスに置き換えます (SQL サーバー ロールの %.DBEngineなど)。
ワークロードの正常性状態
SELECT HealthState =
CASE
WHEN MEV.HealthState = 1 THEN 'Healthy'
WHEN MEV.HealthState = 2 THEN 'Warning'
WHEN MEV.HealthState = 3 THEN 'Critical'
ELSE 'Uninitialized'
END,
CAST(COUNT(*) AS DECIMAL(5, 2)) AS servers
FROM ${Database}.[dbo].[ManagedEntityGenericView] MEV
INNER JOIN ${Database}.[dbo].[ManagedTypeView] MTV ON MTV.Id = MEV.MonitoringClassId and MTV.name like '%.<Monitoring Object Type>'
INNER JOIN ${Database}.[dbo].[ManagementPackView] MPV ON MPV.Id = MTV.ManagementPackId and MPV.name like '<MP name Prefix>'
GROUP BY MEV.HealthState
ORDER BY MEV.HealthState
ワークロードの正常性とそれらに対する新しいアラートの数
SELECT MEV.Name
,HealthState =
CASE
WHEN MEV.HealthState = 1 THEN 'Healthy'
WHEN MEV.HealthState = 2 THEN 'Warning'
WHEN MEV.HealthState = 3 THEN 'Critical'
ELSE 'Uninitialized'
END
,NewAlerts = COUNT(AV.ResolutionState)
FROM ${Database}.[dbo].[ManagedEntityGenericView] MEV
INNER JOIN ${Database}.[dbo].[ManagedTypeView] MTV ON MTV.Id = MEV.MonitoringClassId and MTV.name like '%.<Monitoring Object Type>'
INNER JOIN ${Database}.[dbo].[ManagementPackView] MPV ON MPV.Id = MTV.ManagementPackId and MPV.name like '%<MP name prefix>%'
INNER JOIN ${Database}.[dbo].[AlertView] AV ON AV.MonitoringClassId = MTV.Id and AV.ResolutionState = 0 AND $__timeFilter(TimeRaised)
GROUP BY MEV.Name, HealthState, AV.ResolutionState
ワークロード上の上位のイベント
SELECT EventDescription = LT5.LTValue
,Count(*) Occurences
,AffectedSQLServers = Count(DISTINCT(EV.LoggingComputer))
FROM ${Database}.[dbo].[EventView] EV
INNER JOIN ${Database}.[dbo].[ManagedTypeView] MTV ON MTV.Id = EV.ClassId
INNER JOIN ${Database}.[dbo].[ManagementPackView] MPV ON MPV.Id = MTV.ManagementPackId and MPV.name like '%<MP Name Prefix>%'
INNER JOIN ${Database}.dbo.LocalizedText LT5 ON EV.EventNumberStringId = LT5.LTStringId AND LT5.LanguageCode = 'ENU'
WHERE $__timeFilter(TimeGenerated) AND LevelId < 3
GROUP BY Number, LT5.LTValue
ORDER BY Occurences, AffectedSQLServers DESC;
ワークロードからの上位アラート
SELECT AV.AlertStringName AS Alert
,Occurrence = COUNT(AV.ResolutionState)
,AffectedServers = COUNT(MEV.name)
FROM ${Database}.[dbo].[AlertView] AV
INNER JOIN ${Database}.[dbo].[ManagedTypeView] MTV ON MTV.Id = AV.MonitoringClassId and MTV.name like '%<Monitoring Object Type>'
INNER JOIN ${Database}.[dbo].[ManagementPackView] MPV ON MPV.Id = MTV.ManagementPackId and MPV.name like '%M<MP Name Prefix>%'
INNER JOIN ${Database}.[dbo].[ManagedEntityGenericView] MEV ON MTV.Id = MEV.MonitoringClassId
where AV.ResolutionState = 0 and $__timeFilter(TimeRaised)
GROUP BY AV.AlertStringName, AV.ResolutionState
ワークロード カウンターのパフォーマンス データ クエリ
SELECT PD.TimeSampled
,CASE
WHEN BME.Path IS NOT NULL AND BME.Path <> '' THEN CONCAT(BME.Path, '\', COALESCE(BME.Name, ''))
ELSE COALESCE(BME.Name, '') END AS TagetObjectPath
,ObjectName = PC.ObjectName
,CounterName = PC.CounterName
,Value = PD.SampleValue
FROM dbo.PerformanceDataAllView PD
INNER JOIN dbo.PerformanceSource PS ON PD.PerformanceSourceInternalId = PS.PerformanceSourceInternalId
INNER JOIN dbo.PerformanceCounter PC ON PS.PerformanceCounterId = PC.PerformanceCounterId and CounterName = 'Receive I/Os/sec'
INNER JOIN dbo.BaseManagedEntity BME ON PS.BaseManagedEntityId = BME.BaseManagedEntityId AND BME.IsDeleted = 0
INNER JOIN [dbo].[ManagedTypeView] MTV ON MTV.Id = BME.BaseManagedTypeId
INNER JOIN [dbo].[ManagementPackView] MPV ON MPV.Id = MTV.ManagementPackId and MPV.name like 'Microsoft.SQL%'