この記事では、Azure Monitor ワークスペースを作成および削除する方法について説明します。 Azure Monitor Prometheus 用マネージド サービスを構成する場合は、既存の Monitor ワークスペースを選択するか、新しいものを作成できます。
注
Azure Monitor ワークスペースを作成すると、既定では、<azure-monitor-workspace-name>
という形式のデータ収集ルールとデータ収集エンドポイントが、MA_<azure-monitor-workspace-name>_<___location>_managed
という形式のリソース グループに自動的に作成されます。 リソースまたはリソース グループ名に制限がある Azure ポリシーがある場合は、これらのリソースを評価から除外する 除外を作成 します。
Azure Monitor ワークスペースを作成する
Azure portal で Azure Monitor ワークスペース メニューを開きます。
作成を選択します。
[ Azure Monitor ワークスペースの作成 ] ページで、ワークスペースを作成する サブスクリプション と リソース グループ を選択します。
ワークスペースの 名前 と リージョン を指定します。
[ 確認と作成 ] を選択してワークスペースを作成します。
次のコマンドを用い、Azure CLI を使用して Azure Monitor ワークスペースを作成します。
az monitor account create --name <azure-monitor-workspace-name> --resource-group <resource-group-name> --___location <___location>
詳細については、Azure CLI for Azure Monitor ワークスペースに関するページを参照してください。
Azure Monitor ワークスペースを作成するには、次のいずれかの Resource Manager テンプレートと 標準のデプロイ オプションを使用します。
{
"$schema": "http://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"type": "string"
},
"___location": {
"type": "string",
"defaultValue": ""
}
},
"resources": [
{
"type": "microsoft.monitor/accounts",
"apiVersion": "2021-06-03-preview",
"name": "[parameters('name')]",
"___location": "[if(empty(parameters('___location')), resourceGroup().___location, parameters('___location'))]"
}
]
}
@description('Specify the name of the workspace.')
param workspaceName string
@description('Specify the ___location for the workspace.')
param ___location string = resourceGroup().___location
resource workspace 'microsoft.monitor/accounts@2021-06-03-preview' = {
name: workspaceName
___location: ___location
}
Azure Monitor ワークスペースを作成すると、新しいリソース グループが作成されます。 リソース グループ名の形式は MA_<azure-monitor-workspace-name>_<___location>_managed
です。この場合、トークン化された要素は小文字です。 リソース グループに含まれる内容は、データ収集エンドポイントと、ワークスペースと同じ名前のデータ収集ルールの両方です。 ワークスペースを削除すると、リソース グループとそのリソースが自動的に削除されます。
Prometheus の Azure Monitor マネージド サービスを Azure Monitor ワークスペースに接続するには、「AKS クラスターから Prometheus メトリックを収集する」を参照してください。
Azure Monitor ワークスペースを削除する
Azure Monitor ワークスペースを削除する場合、 Log Analytics ワークスペースとは異なり、論理的な削除操作はありません。 ワークスペース内のデータはすぐに削除されます。回復オプションはありません。
Azure portal で Azure Monitor ワークスペース メニューを開きます。
ワークスペースを選択します。
[ 削除] を選択します。
AzureMonitor ワークスペースを削除するには、az resource delete
を使用します。
例えば次が挙げられます。
az monitor account delete --name <azure-monitor-workspace-name> --resource-group <resource-group-name>
詳細については、Azure CLI for Azure Monitor ワークスペースに関するページを参照してください。
Grafana ワークスペースをリンクする
Azure Monitor ワークスペースを Azure Managed Grafana ワークスペースに接続して、Grafana が Grafana ダッシュボードで Azure Monitor ワークスペース データを使用できるようにします。 Azure Monitor ワークスペースは複数の Grafana ワークスペースに接続でき、Grafana ワークスペースは複数の Azure Monitor ワークスペースに接続できます。 Azure Managed Grafana と Azure Monitor ワークスペースは、異なるリージョンに配置できます。
セルフマネージド Grafana インスタンスを Azure Monitor ワークスペースにリンクするには、「Grafana を Azure Monitor Prometheus メトリックに接続する」を参照してください。
注
Azure Monitor ワークスペースをデータ ソースとして Grafana に追加すると、Prometheus_<azure monitor workspace query endpoint>
として一覧表示されます。
- Azure portal で Azure Monitor ワークスペース メニューを開きます。
- ワークスペースを選択します。
-
リンクされた Grafana ワークスペースを選択してください。
- Grafana ワークスペースを選択します。
監視している Azure Kubernetes Service クラスターを更新して、Azure Monitor ワークスペースと Grafana ワークスペースの間にリンクを作成します。
クラスターが Azure Monitor Prometheus 用マネージド サービスにデータを送信するように既に構成されている場合は、まず、次のコマンドを使用して無効にする必要があります。
az aks update --disable-azure-monitor-metrics -g <cluster-resource-group> -n <cluster-name>
その後、次のコマンドを使用して有効または再度有効にします。
az aks update --enable-azure-monitor-metrics -n <cluster-name> -g <cluster-resource-group> --azure-monitor-workspace-resource-id
<azure-monitor-workspace-name-resource-id> --grafana-resource-id <grafana-workspace-name-resource-id>
アウトプット
"azureMonitorProfile": {
"metrics": {
"enabled": true,
"kubeStateMetrics": {
"metricAnnotationsAllowList": "",
"metricLabelsAllowlist": ""
}
}
}
次のステップ