|
| 1 | +--- |
| 2 | +title: Query Prometheus metrics using Azure workbooks (preview) |
| 3 | +description: Query Prometheus metrics in the portal using Azure Workbooks. |
| 4 | +author: EdB-MSFT |
| 5 | +ms.topic: conceptual |
| 6 | +ms.date: 01/18/2023 |
| 7 | +ms.author: edbaynash |
| 8 | +--- |
| 9 | + |
| 10 | +# Query Prometheus metrics using Azure workbooks (preview) |
| 11 | + |
| 12 | +Create dashboards powered by Azure Monitor managed service for Prometheus using [Azure Workbooks](../visualize/workbooks-overview.md). |
| 13 | +This article introduces workbooks for Azure Monitor workspaces and shows you how to query Prometheus metrics using Azure workbooks and PromQL query language. |
| 14 | + |
| 15 | +## Pre-requisites |
| 16 | +To query Prometheus metrics from an Azure Monitor workspace you need the following: |
| 17 | +- An Azure Monitor workspace. To create an Azure Monitor workspace see [Create an Azure Monitor Workspace](./azure-monitor-workspace-overview.md?tabs=azure-portal.md). |
| 18 | +- Your Azure Monitor workspace must be [collecting Prometheus metrics](./prometheus-metrics-enable.md) from an AKS cluster. |
| 19 | +- You have the **Monitoring Data Reader** role assigned for the Azure Monitor workspace. |
| 20 | + |
| 21 | +> [!NOTE] |
| 22 | +> Querying data from an Azure Monitor workspace is a data plane operation. Even if you are an owner or have elevated control plane access, you still need to assign the Monitoring Data Reader role. For more information, see [Azure control and data plane](../../azure-resource-manager/management/control-plane-and-data-plane.md). |
| 23 | +
|
| 24 | +## Prometheus Explorer workbook |
| 25 | +Azure Monitor workspaces include an exploration workbook to query your Prometheus metrics. |
| 26 | + |
| 27 | +1. From the Azure Monitor workspace overview page, select **Workbooks** |
| 28 | + |
| 29 | +1. In the Azure Monitor workspace gallery, select the **Prometheus Explorer** workbook tile. |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +A workbook has the following input options: |
| 34 | +- **Time Range**. Select the period of time that you want to include in your query. Select **Custom** to set a start and end time. |
| 35 | +- **PromQL**. Enter the PromQL query to retrieve your data. For more information about PromQL, see [Querying Prometheus](https://prometheus.io/docs/prometheus/latest/querying/basics/#querying-prometheus). |
| 36 | +- **Graph**, **Grid**, and **Dimensions** tabs. Switch between a graphic, tabular and dimensional view of the query output. |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | +## Create a Prometheus workbook |
| 41 | + |
| 42 | +Workbooks supports many visualizations and Azure integrations. For more information about Azure Workbooks, see [Creating an Azure Workbook](../visualize/workbooks-create-workbook.md). |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +1. From your Azure Monitor workspace select **Workbooks**. |
| 47 | + |
| 48 | +1. Select **New**. |
| 49 | +1. In the new workbook, select **Add**, and select **Add query** from the dropdown. |
| 50 | +:::image type="content" source="./media/prometheus-workbooks/prometheus-workspace-add-query.png" alt-text="A screenshot showing the add content dropdown in a blank workspace."::: |
| 51 | +1. Azure Workbooks use [data sources](../visualize/workbooks-data-sources.md#prometheus-preview) to set the source scope the data they present. To query Prometheus metrics, select the **Data source** dropdown, and choose **Prometheus (preview)** . |
| 52 | +1. From the **Azure Monitor workspace** dropdown, select your workspace. |
| 53 | +1. Select your query type from **Prometheus query type** dropdown. |
| 54 | +1. Write your PromQL query in the **Prometheus Query** field. |
| 55 | +1. Select **Run Query** button. |
| 56 | +1. Select the **Done Editing** at the bottom of the section and save your work |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +## Troubleshooting |
| 61 | + |
| 62 | +If your workbook query does not return data: |
| 63 | + |
| 64 | +- Check that you have Monitoring Data Reader role permissions assigned through Access Control (IAM) in your Azure Monitor workspace |
| 65 | +- Verify that you have turned on metrics collection in the Monitored clusters blade of your Azure Monitor workspace. |
| 66 | + |
| 67 | + |
| 68 | +## Next steps |
| 69 | +* [Collect Prometheus metrics from AKS cluster (preview)](./prometheus-metrics-enable.md) |
| 70 | +* [Azure Monitor workspace (preview)](./azure-monitor-workspace-overview.md) |
| 71 | +* [Use Azure Monitor managed service for Prometheus (preview) as data source for Grafana using managed system identity](./prometheus-grafana.md) |
0 commit comments