Skip to content

Commit ecfc0e8

Browse files
Merge pull request #226020 from Sohamdg081992/AddBicepDocumentation
Add doc for bicep support for prometheus metrics
2 parents 33c67c4 + 6bc1ecc commit ecfc0e8

File tree

1 file changed

+95
-26
lines changed

1 file changed

+95
-26
lines changed

articles/azure-monitor/essentials/prometheus-metrics-enable.md

Lines changed: 95 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,12 @@ The output will be similar to the following:
119119
- If the Azure Managed Grafana instance is in a subscription other than the Azure Monitor Workspaces subscription, then please register the Azure Monitor Workspace subscription with the `Microsoft.Dashboard` resource provider following this [documentation](/azure-resource-manager/management/resource-providers-and-types#register-resource-provider.md#register-resource-provider).
120120
- The Azure Monitor workspace and Azure Managed Grafana workspace must already be created.
121121
- The template needs to be deployed in the same resource group as the Azure Managed Grafana workspace.
122+
- Users with 'User Access Administrator' role in the subscription of the AKS cluster can be able to enable 'Monitoring Data Reader' role directly by deploying the template.
122123

123124

124125
### Retrieve required values for Grafana resource
125126
From the **Overview** page for the Azure Managed Grafana instance in the Azure portal, select **JSON view**.
126127

127-
Copy the value of the `principalId` field for the `SystemAssigned` identity.
128-
129-
```json
130-
"identity": {
131-
"principalId": "00000000-0000-0000-0000-000000000000",
132-
"tenantId": "00000000-0000-0000-0000-000000000000",
133-
"type": "SystemAssigned"
134-
},
135-
```
136-
137128
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.
138129

139130
```json
@@ -151,15 +142,6 @@ If you're using an existing Azure Managed Grafana instance that already has been
151142
}
152143
```
153144

154-
### Assign role to system identity
155-
The Azure Managed Grafana resource requires the `Monitoring Data Reader` role to read data from the Azure Monitor Workspace.
156-
157-
1. From the **Access control (IAM)** page for the Azure Managed Grafana instance in the Azure portal, select **Add** and then **Add role assignment**.
158-
2. Select `Monitoring Data Reader`.
159-
3. Select **Managed identity** and then **Select members**.
160-
4. Select the **system-assigned managed identity** with the `principalId` from the Grafana resource.
161-
5. Click **Select** and then **Review+assign**.
162-
163145
### Download and edit template and parameter file
164146

165147
1. Download the template at [https://aka.ms/azureprometheus-enable-arm-template](https://aka.ms/azureprometheus-enable-arm-template) and save it as **existingClusterOnboarding.json**.
@@ -207,9 +189,96 @@ The Azure Managed Grafana resource requires the `Monitoring Data Reader` role t
207189
}
208190
````
209191

210-
In this json, `full_resource_id_1` and `full_resource_id_2` were already in the Azure Managed Grafana resource JSON, and they're added here to the ARM template. If you have no existing Grafana integrations, then don't include these entries for `full_resource_id_1` and `full_resource_id_2`.
192+
In this json, `full_resource_id_1` and `full_resource_id_2` were already in the Azure Managed Grafana resource JSON, and they're added here to the ARM template. If you have no existing Grafana integrations, then don't include these entries for `full_resource_id_1` and `full_resource_id_2`.
193+
194+
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.
195+
196+
## [Bicep](#tab/bicep)
197+
198+
### Prerequisites
199+
200+
- 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`.
201+
- The Azure Monitor workspace and Azure Managed Grafana workspace must already be created.
202+
- The template needs to be deployed in the same resource group as the Azure Managed Grafana workspace.
203+
- Users with 'User Access Administrator' role in the subscription of the AKS cluster can be able to enable 'Monitoring Data Reader' role directly by deploying the template.
204+
205+
### Minor Limitation while deploying through bicep
206+
Currently in bicep, there is no way to explicitly "scope" the Monitoring Data Reader role assignment on a string parameter "resource id" for Azure Monitor Workspace (like in ARM template). Bicep expects a value of type "resource | tenant" and currently there is no rest api [spec](https://github.com/Azure/azure-rest-api-specs) for Azure Monitor Workspace. So, as a workaround, the default scoping for Monitoring Data Reader role is on the resource group and thus the role is applied on the same Azure monitor workspace (by inheritance) which is the expected behavior. Thus, after deploying this bicep template, the Grafana resource will get read permissions in all the Azure Monitor Workspaces under the subscription.
207+
208+
209+
### Retrieve required values for Grafana resource
210+
211+
From the **Overview** page for the Azure Managed Grafana instance in the Azure portal, select **JSON view**.
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.
214+
215+
```json
216+
"properties": {
217+
"grafanaIntegrations": {
218+
"azureMonitorWorkspaceIntegrations": [
219+
{
220+
"azureMonitorWorkspaceResourceId": "full_resource_id_1"
221+
},
222+
{
223+
"azureMonitorWorkspaceResourceId": "full_resource_id_2"
224+
}
225+
]
226+
}
227+
}
228+
```
229+
230+
### Download and edit templates and parameter file
231+
232+
1. Download the main bicep template from [here](https://aka.ms/azureprometheus-enable-bicep-template) and save it as **FullAzureMonitorMetricsProfile.bicep**.
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+
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+
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.
237+
238+
| Parameter | Value |
239+
|:---|:---|
240+
| `azureMonitorWorkspaceResourceId` | Resource ID for the Azure Monitor workspace. Retrieve from the **JSON view** on the **Overview** page for the Azure Monitor workspace. |
241+
| `azureMonitorWorkspaceLocation` | Location of the Azure Monitor workspace. Retrieve from the **JSON view** on the **Overview** page for the Azure Monitor workspace. |
242+
| `clusterResourceId` | Resource ID for the AKS cluster. Retrieve from the **JSON view** on the **Overview** page for the cluster. |
243+
| `clusterLocation` | Location of the AKS cluster. Retrieve from the **JSON view** on the **Overview** page for the cluster. |
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. |
246+
| `grafanaResourceId` | Resource ID for the managed Grafana instance. Retrieve from the **JSON view** on the **Overview** page for the Grafana instance. |
247+
| `grafanaLocation` | Location for the managed Grafana instance. Retrieve from the **JSON view** on the **Overview** page for the Grafana instance. |
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+
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:
252+
253+
```json
254+
{
255+
"type": "Microsoft.Dashboard/grafana",
256+
"apiVersion": "2022-08-01",
257+
"name": "[split(parameters('grafanaResourceId'),'/')[8]]",
258+
"sku": {
259+
"name": "[parameters('grafanaSku')]"
260+
},
261+
"location": "[parameters('grafanaLocation')]",
262+
"properties": {
263+
"grafanaIntegrations": {
264+
"azureMonitorWorkspaceIntegrations": [
265+
{
266+
"azureMonitorWorkspaceResourceId": "full_resource_id_1"
267+
},
268+
{
269+
"azureMonitorWorkspaceResourceId": "full_resource_id_2"
270+
},
271+
{
272+
"azureMonitorWorkspaceResourceId": "[parameters('azureMonitorWorkspaceResourceId')]"
273+
}
274+
]
275+
}
276+
}
277+
````
278+
279+
In this json, `full_resource_id_1` and `full_resource_id_2` were already in the Azure Managed Grafana resource JSON, and they're added here to the ARM template. If you have no existing Grafana integrations, then don't include these entries for `full_resource_id_1` and `full_resource_id_2`.
211280

212-
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.
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.
213282

214283

215284
### Deploy template
@@ -224,8 +293,6 @@ Deploy the template with the parameter file using any valid method for deploying
224293

225294
---
226295

227-
228-
229296
## Verify Deployment
230297

231298
Run the following command to which verify that the daemon set was deployed properly:
@@ -261,13 +328,13 @@ ama-metrics-ksm-5fcf8dffcd 1 1 1 11h
261328
## Limitations
262329

263330
- CPU and Memory requests and limits can't be changed for Container insights metrics addon. If changed, they'll be reconciled and replaced by original values in a few seconds.
264-
- Metrics addon doesn't work on AKS clusters configured with HTTP proxy.
331+
- Metrics addon doesn't work on AKS clusters configured with HTTP proxy.
265332

266333

267334
## Uninstall metrics addon
268-
Currently, Azure CLI is the only option to remove the metrics addon and stop sending Prometheus metrics to Azure Monitor managed service for Prometheus.
335+
Currently, Azure CLI is the only option to remove the metrics addon and stop sending Prometheus metrics to Azure Monitor managed service for Prometheus.
269336

270-
If you don't already have it, install the aks-preview extension with the following command.
337+
If you don't already have it, install the aks-preview extension with the following command.
271338

272339
The `aks-preview` extension needs to be installed using the following command. For more information on how to install a CLI extension, see [Use and manage extensions with the Azure CLI](/cli/azure/azure-cli-extensions-overview).
273340

@@ -336,7 +403,9 @@ When you allow a default Azure Monitor workspace to be created when you install
336403

337404
## Next steps
338405

406+
339407
- [See the default configuration for Prometheus metrics](./prometheus-metrics-scrape-default.md).
340408
- [Customize Prometheus metric scraping for the cluster](./prometheus-metrics-scrape-configuration.md).
341409
- [Use Azure Monitor managed service for Prometheus (preview) as data source for Grafana](./prometheus-grafana.md)
342410
- [Configure self-hosted Grafana to use Azure Monitor managed service for Prometheus (preview)](./prometheus-self-managed-grafana-azure-active-directory.md)
411+

0 commit comments

Comments
 (0)