You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-monitor/essentials/prometheus-metrics-enable.md
+48-13Lines changed: 48 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,14 +51,14 @@ Use `az aks update` with the `-enable-azuremonitormetrics` option to install the
51
51
52
52
**Create a new default Azure Monitor workspace.**<br>
53
53
If no Azure Monitor Workspace is specified, then a default Azure Monitor Workspace will be created in the `DefaultRG-<cluster_region>` following the format `DefaultAzureMonitorWorkspace-<mapped_region>`.
54
-
This Azure Monitor Workspace will be in the region specific in [Region mappings](#region-mappings).
54
+
This Azure Monitor Workspace is in the region specific in [Region mappings](#region-mappings).
55
55
56
56
```azurecli
57
57
az aks update --enable-azuremonitormetrics -n <cluster-name> -g <cluster-resource-group>
58
58
```
59
59
60
60
**Use an existing Azure Monitor workspace.**<br>
61
-
If the Azure Monitor workspace is linked to one or more Grafana workspaces, then the data will be available in Grafana.
61
+
If the Azure Monitor workspace is linked to one or more Grafana workspaces, then the data is available in Grafana.
62
62
63
63
```azurecli
64
64
az aks update --enable-azuremonitormetrics -n <cluster-name> -g <cluster-resource-group> --azure-monitor-workspace-resource-id <workspace-name-resource-id>
@@ -71,7 +71,7 @@ This creates a link between the Azure Monitor workspace and the Grafana workspac
71
71
az aks update --enable-azuremonitormetrics -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>
72
72
```
73
73
74
-
The output for each command will look similar to the following:
74
+
The output for each command looks similar to the following:
75
75
76
76
```json
77
77
"azureMonitorProfile": {
@@ -88,16 +88,16 @@ The output for each command will look similar to the following:
88
88
#### Optional parameters
89
89
Following are optional parameters that you can use with the previous commands.
90
90
91
-
-`--ksm-metric-annotations-allow-list` is a comma-separated list of Kubernetes annotations keys that will be used in the resource's labels metric. By default the metric contains only name and namespace labels. To include additional annotations provide a list of resource names in their plural form and Kubernetes annotation keys, you would like to allow for them. A single `*` can be provided per resource instead to allow any annotations, but that has severe performance implications.
92
-
-`--ksm-metric-labels-allow-list` is a comma-separated list of additional Kubernetes label keys that will be used in the resource's labels metric. By default the metric contains only name and namespace labels. To include additional labels provide a list of resource names in their plural form and Kubernetes label keys you would like to allow for them. A single `*` can be provided per resource instead to allow any labels, but that has severe performance implications.
91
+
-`--ksm-metric-annotations-allow-list` is a comma-separated list of Kubernetes annotations keys that will be used in the resource's labels metric. By default the metric contains only name and namespace labels. To include more annotations provide a list of resource names in their plural form and Kubernetes annotation keys, you would like to allow for them. A single `*` can be provided per resource instead to allow any annotations, but that has severe performance implications.
92
+
-`--ksm-metric-labels-allow-list` is a comma-separated list of more Kubernetes label keys that will be used in the resource's labels metric. By default the metric contains only name and namespace labels. To include more labels provide a list of resource names in their plural form and Kubernetes label keys, you would like to allow for them. A single `*` can be provided per resource instead to allow any labels, but that has severe performance implications.
93
93
94
94
**Use annotations and labels.**
95
95
96
96
```azurecli
97
97
az aks update --enable-azuremonitormetrics -n <cluster-name> -g <cluster-resource-group> --ksm-metric-labels-allow-list "namespaces=[k8s-label-1,k8s-label-n]" --ksm-metric-annotations-allow-list "pods=[k8s-annotation-1,k8s-annotation-n]"
98
98
```
99
99
100
-
The output will be similar to the following:
100
+
The output is similar to the following:
101
101
102
102
```json
103
103
"azureMonitorProfile": {
@@ -125,7 +125,7 @@ The output will be similar to the following:
125
125
### Retrieve required values for Grafana resource
126
126
From the **Overview** page for the Azure Managed Grafana instance in the Azure portal, select **JSON view**.
127
127
128
-
If you're using an existing Azure Managed Grafana instance that already has been linked to an Azure Monitor workspace then you need the list of Grafana integrations. Copy the value of the `azureMonitorWorkspaceIntegrations` field. If it doesn't exist, then the instance hasn't been linked with any Azure Monitor workspace.
128
+
If you're using an existing Azure Managed Grafana instance that already has been linked to an Azure Monitor workspace, then you need the list of Grafana integrations. Copy the value of the `azureMonitorWorkspaceIntegrations` field. If it doesn't exist, then the instance hasn't been linked with any Azure Monitor workspace.
129
129
130
130
```json
131
131
"properties": {
@@ -155,13 +155,13 @@ If you're using an existing Azure Managed Grafana instance that already has been
155
155
|`clusterResourceId`| Resource ID for the AKS cluster. Retrieve from the **JSON view** on the **Overview** page for the cluster. |
156
156
|`clusterLocation`| Location of the AKS cluster. Retrieve from the **JSON view** on the **Overview** page for the cluster. |
157
157
|`metricLabelsAllowlist`| Comma-separated list of Kubernetes labels keys that will be used in the resource's labels metric. |
158
-
|`metricAnnotationsAllowList`| Comma-separated list of additional Kubernetes label keys that will be used in the resource's labels metric. |
158
+
|`metricAnnotationsAllowList`| Comma-separated list of more Kubernetes label keys that will be used in the resource's labels metric. |
159
159
|`grafanaResourceId`| Resource ID for the managed Grafana instance. Retrieve from the **JSON view** on the **Overview** page for the Grafana instance. |
160
160
|`grafanaLocation`| Location for the managed Grafana instance. Retrieve from the **JSON view** on the **Overview** page for the Grafana instance. |
161
161
|`grafanaSku`| SKU for the managed Grafana instance. Retrieve from the **JSON view** on the **Overview** page for the Grafana instance. Use the **sku.name**. |
162
162
163
163
164
-
4. Open the template file and update the `grafanaIntegrations` property at the end of the file with the values that you retrieved from the Grafana instance. This will be similar to the following:
164
+
4. Open the template file and update the `grafanaIntegrations` property at the end of the file with the values that you retrieved from the Grafana instance. This is similar to the following:
165
165
166
166
```json
167
167
{
@@ -210,7 +210,7 @@ Currently in bicep, there is no way to explicitly "scope" the Monitoring Data Re
210
210
211
211
From the **Overview** page for the Azure Managed Grafana instance in the Azure portal, select **JSON view**.
212
212
213
-
If you're using an existing Azure Managed Grafana instance that already has been linked to an Azure Monitor workspace then you need the list of Grafana integrations. Copy the value of the `azureMonitorWorkspaceIntegrations` field. If it doesn't exist, then the instance hasn't been linked with any Azure Monitor workspace.
213
+
If you're using an existing Azure Managed Grafana instance that already has been linked to an Azure Monitor workspace, then you need the list of Grafana integrations. Copy the value of the `azureMonitorWorkspaceIntegrations` field. If it doesn't exist, then the instance hasn't been linked with any Azure Monitor workspace.
214
214
215
215
```json
216
216
"properties": {
@@ -233,7 +233,7 @@ If you're using an existing Azure Managed Grafana instance that already has been
233
233
2. Download the parameter file from [here](https://aka.ms/azureprometheus-enable-bicep-template-parameters) and save it as **FullAzureMonitorMetricsProfileParameters.json** in the same directory as the main bicep template.
234
234
3. Download the [nested_azuremonitormetrics_dcra_clusterResourceId.bicep](https://aka.ms/nested_azuremonitormetrics_dcra_clusterResourceId) and [nested_azuremonitormetrics_profile_clusterResourceId.bicep](https://aka.ms/nested_azuremonitormetrics_profile_clusterResourceId) files in the same directory as the main bicep template.
235
235
4. Edit the values in the parameter file.
236
-
5. The main bicep template creates all the required resources and uses 2 modules for creating the dcra and monitormetrics profile resources from the other two bicep files.
236
+
5. The main bicep template creates all the required resources and uses two modules for creating the dcra and monitormetrics profile resources from the other two bicep files.
237
237
238
238
| Parameter | Value |
239
239
|:---|:---|
@@ -242,13 +242,13 @@ If you're using an existing Azure Managed Grafana instance that already has been
242
242
| `clusterResourceId` | Resource ID for the AKS cluster. Retrieve from the **JSON view** on the **Overview** page for the cluster. |
243
243
| `clusterLocation` | Location of the AKS cluster. Retrieve from the **JSON view** on the **Overview** page for the cluster. |
244
244
| `metricLabelsAllowlist` | Comma-separated list of Kubernetes labels keys that will be used in the resource's labels metric. |
245
-
| `metricAnnotationsAllowList` | Comma-separated list of additional Kubernetes label keys that will be used in the resource's labels metric. |
245
+
| `metricAnnotationsAllowList` | Comma-separated list of more Kubernetes label keys that will be used in the resource's labels metric. |
246
246
| `grafanaResourceId` | Resource ID for the managed Grafana instance. Retrieve from the **JSON view** on the **Overview** page for the Grafana instance. |
247
247
| `grafanaLocation` | Location for the managed Grafana instance. Retrieve from the **JSON view** on the **Overview** page for the Grafana instance. |
248
248
| `grafanaSku` | SKU for the managed Grafana instance. Retrieve from the **JSON view** on the **Overview** page for the Grafana instance. Use the **sku.name**. |
249
249
250
250
251
-
6. Open the template file and update the `grafanaIntegrations` property at the end of the file with the values that you retrieved from the Grafana instance. This will be similar to the following:
251
+
6. Open the template file and update the `grafanaIntegrations` property at the end of the file with the values that you retrieved from the Grafana instance. This is similar to the following:
252
252
253
253
```json
254
254
{
@@ -280,6 +280,41 @@ In this json, `full_resource_id_1` and `full_resource_id_2` were already in the
280
280
281
281
The final `azureMonitorWorkspaceResourceId` entry is already in the template and is used to link to the Azure Monitor Workspace resource ID provided in the parameters file.
282
282
283
+
## [Azure Policy](#tab/azurepolicy)
284
+
285
+
### Prerequisites
286
+
287
+
- Register the `AKS-PrometheusAddonPreview` feature flag in the Azure Kubernetes clusters subscription with the following command in Azure CLI: `az feature register --namespace Microsoft.ContainerService --name AKS-PrometheusAddonPreview`.
288
+
- The Azure Monitor workspace and Azure Managed Grafana workspace must already be created.
289
+
290
+
### Download Azure policy rules and parameters and deploy
291
+
292
+
1. Download the main Azure policy rules template from [here](https://aka.ms/AddonPolicyMetricsProfile) and save it as **AddonPolicyMetricsProfile.rules.json**.
293
+
2. Download the parameter file from [here](https://aka.ms/AddonPolicyMetricsProfile.parameters) and save it as **AddonPolicyMetricsProfile.parameters.json** in the same directory as the rules template.
294
+
3. Create the policy definition using a command like : `az policy definition create --name "(Preview) Prometheus Metrics addon" --display-name "(Preview) Prometheus Metrics addon" --mode Indexed --metadata version=1.0.0 category=Kubernetes --rules .\AddonPolicyMetricsProfile.rules.json --params .\AddonPolicyMetricsProfile.parameters.json`
295
+
4. After creating the policy definition, go to Azure portal -> Policy -> Definitions and select the Policy definition you created.
296
+
5. Click on 'Assign' and then go to the 'Parameters' tab and fill in the details. Then click 'Review + Create'.
297
+
6. Now that the policy is assigned to the subscription, whenever you create a new cluster, which does not have Prometheus enabled, the policy will run and deploy the resources. If you want to apply the policy to existing AKS cluster, create a 'Remediation task' for that AKS cluster resource after going to the 'Policy Assignment'.
298
+
7. Now you should see metrics flowing in the existing linked Grafana resource, which is linked with the corresponding Azure Monitor Workspace.
299
+
300
+
In case you create a new Managed Grafana resource from Azure portal, please link it with the corresponding Azure Monitor Workspace from the 'Linked Grafana Workspaces' tab of the relevant Azure Monitor Workspace page. Please assign the role 'Monitoring Data Reader' to the Grafana MSI on the Azure Monitor Workspace resource so that it can read data for displaying the charts, using the instructions below.
301
+
302
+
1. From the **Overview** page for the Azure Managed Grafana instance in the Azure portal, select **JSON view**.
303
+
304
+
2. Copy the value of the `principalId` field for the `SystemAssigned` identity.
0 commit comments