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: The specific time series data you want to analyze
  • Label filter: Key-value pairs that narrow down the dataset
  • Operation: Functions that modify or process the data

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

  1. Click the Metric drop-down list to select a metric.
  2. Select a metric from the list, for example node_cpu_usage_seconds_total.
  3. (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.
  4. Click + Operations to add a function to your query.
  5. Select a function from the menu. For example, select Range > Rate and $__rate_interval.
  6. Click + Operations again to add another operation.
  7. Select another function. For example, select Aggregations > Sum.
  8. 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 (optional)

At this point in your journey, you can explore the following paths:

Introduction to histograms and heatmaps

Metrics explorer

Label filters

Operations


page 5 of 8