|
| 1 | +--- |
| 2 | +title: Azure Monitor metrics explorer with PromQL (Preview) |
| 3 | +description: Learn about Azure Monitor metrics explorer with Prometheus query language support. |
| 4 | +author: EdB-MSFT |
| 5 | +ms.service: azure-monitor |
| 6 | +ms-author: edbaynash |
| 7 | +ms.topic: conceptual |
| 8 | +ms.date: 04/01/2024 |
| 9 | +ms.reviewer: priyamishra |
| 10 | + |
| 11 | +# Customer intent: As an Azure Monitor user, I want to learn how to use Azure Monitor metrics explorer with PromQL. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +# Azure Monitor metrics explorer with PromQL (Preview) |
| 16 | + |
| 17 | +Azure Monitor metrics explorer with PromQL (Preview) allows you to analyze metrics using Prometheus query language (PromQL) for metrics stored in an Azure Monitor workspace. |
| 18 | + |
| 19 | +Azure Monitor metrics explorer with PromQL (Preview) is available from the **Metrics** menu item of any Azure Monitor workspace. You can query metrics from form Azure Monitor workspaces using PromQL or any other Azure resource using the query builder. |
| 20 | + |
| 21 | +> [!NOTE] |
| 22 | +> You must have the *Monitoring Reader* role at the subscription level to visualize metrics across multiple resources, resource groups, or a subscription. For more information, see [Assign Azure roles in the Azure portal](/azure/role-based-access-control/role-assignments-portal). |
| 23 | +
|
| 24 | + |
| 25 | +## Create a chart |
| 26 | + |
| 27 | +The chart pane has two options for charting a metric: |
| 28 | +- Add with editor. |
| 29 | +- Add with builder. |
| 30 | + |
| 31 | +Adding a chart with the editor allows you to enter a PromQL query to retrieve metrics data. The editor provides syntax highlighting and intellisense for PromQL queries. Currently, queries are limited to the metrics stored in an Azure Monitor workspace. For more information on PromQL, see [Querying Prometheus](https://prometheus.io/docs/prometheus/latest/querying/basics/). |
| 32 | + |
| 33 | + |
| 34 | +Adding a chart with the builder allows you to select metrics from any of your Azure resources. The builder provides a list of metrics available in the selected scope. Select the metric, aggregation type, and chart type from the builder. The builder can't be used to chart metrics stored in an Azure Monitor workspace. |
| 35 | + |
| 36 | + |
| 37 | +### Create a chart with the editor and PromQL |
| 38 | + |
| 39 | +To add a metric using the query editor: |
| 40 | + |
| 41 | +1. Select **Add metric** and select **Add with editor** from the dropdown. |
| 42 | + |
| 43 | +1. Select a **Scope** from the dropdown list. This scope is the Azure Monitor workspace where the metrics are stored. |
| 44 | +1. Enter a PromQL query in the editor field, or select a single metric from **Metric** dropdown. |
| 45 | +1. Select **Run** to run the query and display the results in the chart. You can customize the chart by selecting the gear-wheel icon. You can change the chart title, add annotations, and set the time range for the chart. |
| 46 | + |
| 47 | +:::image type="content" source="./media/metrics-explorer/add-metric-with-editor.png" lightbox="./media/metrics-explorer/add-metric-with-editor.png" alt-text="A screenshot showing adding a metric using the editor." ::: |
| 48 | + |
| 49 | +### Create a chart with the builder |
| 50 | + |
| 51 | +To add a metric with the builder: |
| 52 | + |
| 53 | +1. Select **Add metric** and select **Add with builder** from the dropdown. |
| 54 | + |
| 55 | +1. Select a **Scope**. The scope can be any Azure resource in your subscription. |
| 56 | +1. Select a **Metric Namespace** from the dropdown list. The metrics namespace is the category of the metric. |
| 57 | +1. Select a **Metric** from the dropdown list. |
| 58 | +1. Select the **Aggregation** type from the dropdown list. |
| 59 | + |
| 60 | + For more information on the selecting scope, metrics, and aggregation, see [Analyze metrics](/azure/azure-monitor/essentials/analyze-metrics#set-the-resource-scope). |
| 61 | + |
| 62 | +:::image type="content" source="./media/metrics-explorer/add-metric-with-builder.png" lightbox="./media/metrics-explorer/add-metric-with-builder.png" alt-text="A screenshot showing adding a metric using the builder in the metrics explorer." ::: |
| 63 | + |
| 64 | +Metrics are displayed by default as a line chart. Select your preferred chart type from the dropdown list in the toolbar. Customize the chart by selecting the gear-wheel icon. You can change the chart title, add annotations, and set the time range for the chart. |
| 65 | + |
| 66 | +## Multiple metrics and charts |
| 67 | +Each workspace can host multiple charts. Each chart can contain multiple metrics. |
| 68 | + |
| 69 | +### Add a metric |
| 70 | + |
| 71 | +Add multiple metrics to the chart by selecting **Add metric**. Use either the builder or the editor to add metrics to the chart. |
| 72 | + |
| 73 | +> [!NOTE] |
| 74 | +> Using both the code editor and query builder on the same chart is not supported in the Preview release of Azure Monitor metrics explorer and may result in unexpected behavior. |
| 75 | +
|
| 76 | + |
| 77 | +### Add a new chart |
| 78 | + |
| 79 | +Create additional charts by selecting **New chart**. Each chart can have multiple metrics and different chart types and settings. |
| 80 | + |
| 81 | +Time range and granularity are applied to all the charts in the workspace. |
| 82 | + |
| 83 | +:::image type="content" source="./media/metrics-explorer/create-multiple-charts.png" lightbox="./media/metrics-explorer/create-multiple-charts.png" alt-text="A screenshot showing multiple charts."::: |
| 84 | + |
| 85 | +### Remove a chart |
| 86 | + |
| 87 | +To remove a chart, select the ellipsis (**...**) options icon and select **Remove**. |
| 88 | + |
| 89 | +## Configure time range and granularity |
| 90 | + |
| 91 | +Configure the time range and granularity for your metric chart to view data that's relevant to your monitoring scenario. By default, the chart shows the most recent 24 hours of metrics data. |
| 92 | + |
| 93 | +Set the time range for the chart by selecting the time picker in the toolbar. Select a predefined time range, or set a custom time range. |
| 94 | + |
| 95 | + |
| 96 | +Time grain is the frequency of sampling and display of the data points on the chart. Select the time granularity by using the time picker in the metrics explorer. If the data is stored at a lower or more frequent granularity than selected, the metric values displayed are aggregated to the level of granularity selected. The time grain is set to automatic by default. The automatic setting selects the best time grain based on the time range selected. |
| 97 | + |
| 98 | +For more information on configuring time range and granularity, see [Analyze metrics](/azure/azure-monitor/essentials/analyze-metrics#configure-the-time-range). |
| 99 | + |
| 100 | +:::image type="content" source="./media/metrics-explorer/time-picker.png" lightbox="./media/metrics-explorer/time-picker.png" alt-text="A screenshot showing time range picker." ::: |
| 101 | + |
| 102 | +## Chart features |
| 103 | + |
| 104 | +Interact with the charts to gain deeper insights into your metrics data. |
| 105 | +Interactive features include the following: |
| 106 | + |
| 107 | +- Zoom-in. Select and drag to zoom in on a specific area of the chart. |
| 108 | +- Pan. Shift chart left and right along the time axis. |
| 109 | +- Change chart settings such as chart type, Y-axis range, and legends. |
| 110 | +- Save and share charts |
| 111 | + |
| 112 | +For more information on chart features, see [Interactive chart features](/azure/azure-monitor/essentials/analyze-metrics#interactive-chart-features). |
| 113 | + |
| 114 | + |
| 115 | +## Next steps |
| 116 | + |
| 117 | +- [Azure Monitor managed service for Prometheus](/azure/azure-monitor/essentials/prometheus-metrics-overview) |
| 118 | +- [Azure Monitor workspace overview](/azure/azure-monitor/essentials/azure-monitor-workspace-overview) |
| 119 | +- [Understanding metrics aggregation](/azure/azure-monitor/essentials/metrics-aggregation-explained) |
0 commit comments