Skip to content

Commit 6dd1590

Browse files
author
Soham Dasgupta
committed
Add doc for bicep support for prometheus metrics
1 parent a8143c6 commit 6dd1590

File tree

1 file changed

+94
-27
lines changed

1 file changed

+94
-27
lines changed

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

Lines changed: 94 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,12 @@ The output will be similar to the following:
116116
- 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`.
117117
- The Azure Monitor workspace and Azure Managed Grafana workspace must already be created.
118118
- The template needs to be deployed in the same resource group as the Azure Managed Grafana workspace.
119+
- 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.
119120

120121

121122
### Retrieve required values for Grafana resource
122123
From the **Overview** page for the Azure Managed Grafana instance in the Azure portal, select **JSON view**.
123124

124-
Copy the value of the `principalId` field for the `SystemAssigned` identity.
125-
126-
```json
127-
"identity": {
128-
"principalId": "00000000-0000-0000-0000-000000000000",
129-
"tenantId": "00000000-0000-0000-0000-000000000000",
130-
"type": "SystemAssigned"
131-
},
132-
```
133-
134125
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.
135126

136127
```json
@@ -148,15 +139,6 @@ If you're using an existing Azure Managed Grafana instance that already has been
148139
}
149140
```
150141

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

162144
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**.
@@ -204,9 +186,96 @@ The Azure Managed Grafana resource requires the `Monitoring Data Reader` role t
204186
}
205187
````
206188

207-
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`.
189+
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`.
190+
191+
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.
192+
193+
## [Bicep](#tab/bicep)
194+
195+
### Prerequisites
196+
197+
- 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`.
198+
- The Azure Monitor workspace and Azure Managed Grafana workspace must already be created.
199+
- The template needs to be deployed in the same resource group as the Azure Managed Grafana workspace.
200+
- 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.
201+
202+
### Minor Limitation while deploying through bicep
203+
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 inheritence) 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.
204+
205+
206+
### Retrieve required values for Grafana resource
207+
208+
From the **Overview** page for the Azure Managed Grafana instance in the Azure portal, select **JSON view**.
209+
210+
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.
211+
212+
```json
213+
"properties": {
214+
"grafanaIntegrations": {
215+
"azureMonitorWorkspaceIntegrations": [
216+
{
217+
"azureMonitorWorkspaceResourceId": "full_resource_id_1"
218+
},
219+
{
220+
"azureMonitorWorkspaceResourceId": "full_resource_id_2"
221+
}
222+
]
223+
}
224+
}
225+
```
226+
227+
### Download and edit templates and parameter file
228+
229+
1. Download the main bicep template from [here](https://aka.ms/azureprometheus-enable-bicep-template) and save it as **FullAzureMonitorMetricsProfile.bicep**.
230+
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.
231+
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.
232+
4. Edit the values in the parameter file.
233+
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.
234+
235+
| Parameter | Value |
236+
|:---|:---|
237+
| `azureMonitorWorkspaceResourceId` | Resource ID for the Azure Monitor workspace. Retrieve from the **JSON view** on the **Overview** page for the Azure Monitor workspace. |
238+
| `azureMonitorWorkspaceLocation` | Location of the Azure Monitor workspace. Retrieve from the **JSON view** on the **Overview** page for the Azure Monitor workspace. |
239+
| `clusterResourceId` | Resource ID for the AKS cluster. Retrieve from the **JSON view** on the **Overview** page for the cluster. |
240+
| `clusterLocation` | Location of the AKS cluster. Retrieve from the **JSON view** on the **Overview** page for the cluster. |
241+
| `metricLabelsAllowlist` | Comma-separated list of Kubernetes labels keys that will be used in the resource's labels metric. |
242+
| `metricAnnotationsAllowList` | Comma-separated list of additional Kubernetes label keys that will be used in the resource's labels metric. |
243+
| `grafanaResourceId` | Resource ID for the managed Grafana instance. Retrieve from the **JSON view** on the **Overview** page for the Grafana instance. |
244+
| `grafanaLocation` | Location for the managed Grafana instance. Retrieve from the **JSON view** on the **Overview** page for the Grafana instance. |
245+
| `grafanaSku` | SKU for the managed Grafana instance. Retrieve from the **JSON view** on the **Overview** page for the Grafana instance. Use the **sku.name**. |
246+
247+
248+
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:
249+
250+
```json
251+
{
252+
"type": "Microsoft.Dashboard/grafana",
253+
"apiVersion": "2022-08-01",
254+
"name": "[split(parameters('grafanaResourceId'),'/')[8]]",
255+
"sku": {
256+
"name": "[parameters('grafanaSku')]"
257+
},
258+
"location": "[parameters('grafanaLocation')]",
259+
"properties": {
260+
"grafanaIntegrations": {
261+
"azureMonitorWorkspaceIntegrations": [
262+
{
263+
"azureMonitorWorkspaceResourceId": "full_resource_id_1"
264+
},
265+
{
266+
"azureMonitorWorkspaceResourceId": "full_resource_id_2"
267+
},
268+
{
269+
"azureMonitorWorkspaceResourceId": "[parameters('azureMonitorWorkspaceResourceId')]"
270+
}
271+
]
272+
}
273+
}
274+
````
275+
276+
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`.
208277

209-
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.
278+
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.
210279

211280

212281
### Deploy template
@@ -216,8 +285,6 @@ Deploy the template with the parameter file using any valid method for deploying
216285

217286
---
218287

219-
220-
221288
## Verify Deployment
222289

223290
Run the following command to which verify that the daemon set was deployed properly:
@@ -256,13 +323,13 @@ ama-metrics-ksm-5fcf8dffcd 1 1 1 11h
256323
- A data collection rule and data collection endpoint is created with the name `MSPROM-\<cluster-name\>-\<cluster-region\>`. These names can't currently be modified.
257324
- You must get the existing Azure Monitor workspace integrations for a Grafana workspace and update the Resource Manager template with it, otherwise it will overwrite and remove the existing integrations from the grafana workspace.
258325
- 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.
259-
- Metrics addon doesn't work on AKS clusters configured with HTTP proxy.
326+
- Metrics addon doesn't work on AKS clusters configured with HTTP proxy.
260327

261328

262329
## Uninstall metrics addon
263-
Currently, Azure CLI is the only option to remove the metrics addon and stop sending Prometheus metrics to Azure Monitor managed service for Prometheus.
330+
Currently, Azure CLI is the only option to remove the metrics addon and stop sending Prometheus metrics to Azure Monitor managed service for Prometheus.
264331

265-
If you don't already have it, install the aks-preview extension with the following command.
332+
If you don't already have it, install the aks-preview extension with the following command.
266333

267334
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).
268335

@@ -332,4 +399,4 @@ When you allow a default Azure Monitor workspace to be created when you install
332399
## Next steps
333400

334401
- [See the default configuration for Prometheus metrics](prometheus-metrics-scrape-default.md).
335-
- [Customize Prometheus metric scraping for the cluster](prometheus-metrics-scrape-configuration.md).
402+
- [Customize Prometheus metric scraping for the cluster](prometheus-metrics-scrape-configuration.md).

0 commit comments

Comments
 (0)