Write a PromQL query using the Query Builder
Now that you have defined the requirements for your visualization, 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:
Select a metric from the Metric drop-down list.
For example, select
node_cpu_usage_seconds_total
.Did you know?
If you are unsure of the metric name, you can click the Metrics explorer icon and search for the metric by name and type.
(Optional) In the Label filters fields, select a key-value pair and operator.
For example, select
node
,=
, andi-077dec042c9d8a744
.Click + Operations and select a function.
For example, select
Range > Rate
and$__rate_interval
To add another operation, click + Operation and select another function.
For example, select
Aggregation > Sum
.Click Refresh located in the toolbar.
The visualization should populate with data.
At this point in your journey, you can explore the following paths: