---
title: "Write a PromQL query | Grafana Labs"
description: "Learn how to use the Grafana query builder to write a PromQL query"
---

# Write a PromQL query

Now that you have a panel configured, it’s time to write the query. A query is an expression that specifies the dataset to be used in the visualization.

A PromQL query consists of three basic elements:

- **Metric**: A metric represents the specific time series data you want to analyze. It is the foundation of your query and defines the type of data to retrieve. For example, `node_cpu_usage_seconds_total` is a metric that tracks CPU usage over time.
- **Label filter**: A label filter allows you to refine your query by specifying key-value pairs that narrow down the dataset. This helps you focus on specific subsets of data, such as a particular node or instance. For example, a label filter like `node="i-077dec042c9d8a744"` retrieves data only for the specified node.
- **Operation**: An operation modifies or processes the data retrieved by the query. It can perform calculations, aggregations, or transformations to derive meaningful insights. For example, the `rate()` operation calculates the per-second rate of increase for a given metric.

To write a PromQL query using the Query Builder, complete the following steps:

1. Click the **Metric** drop-down list to select a metric.
   
   For example, select `node_cpu_usage_seconds_total`.
2. (Optional) In the **Label filters** fields, select a key-value pair and operator to filter your data. For example, select `node`, `=`, and your specific node ID.
3. Click **+ Operations** to add a function to your query.
   
   For example, select **Range &gt; Rate** and `$__rate_interval`.
4. Click **+ Operations** again to add another operation.
   
   For example, select **Aggregations &gt; Sum**.
5. Click **Refresh** in the toolbar to run the query and populate the visualization with data.

**Did you know?** If you’re unsure of the metric name, click the **Metrics explorer** icon to search for metrics by name and type.

Your visualization should now display data based on your query. In the next milestone, you’ll configure the time range and refresh interval.

* * *

### More to explore

- [Introduction to histograms and heatmaps](/docs/grafana-cloud/introduction/histograms/)
- [Metrics explorer](/docs/grafana-cloud/connect-externally-hosted/data-sources/prometheus/query-editor/#metrics-explorer)
- [Label filters](/docs/grafana-cloud/connect-externally-hosted/data-sources/prometheus/query-editor/#label-filters)
- [Operations](/docs/grafana-cloud/connect-externally-hosted/data-sources/prometheus/query-editor/#operations)
