Create PromQL queries with the query builder
Creating PromQL queries from scratch can take time. To help with the task, Chronosphere includes a tool you can use to construct PromQL queries.
The query builder supports only Prometheus metrics and PromQL.
The query builder is available in Metrics Explorer and when building queries in dashboards.
To open the tool, click Builder when writing a query in Observability Platform. Any changes you make will update your original query.
You can add comments to annotate metrics with information to signify importance, help other users to understand usage context, and turn informal knowledge into institutional knowledge that can be used across your organization.
Builder
The builder contains fields that represent key parts of a PromQL query. As you type in the search boxes for each field, the builder suggests metric names, label names, label values, and function names.
Create the query
Use the text boxes to add values which create the PromQL query:
-
Click the Select a metric box next to Metric. A list of selectable metrics opens. Choose a metric, or search for one.
When reviewing a metric for selection, an additional window opens to the side of the search menu. This window displays:
- The type of metric (for example, gauge).
- A Description. Click the pencil icon to add or edit a description and then click Save.
- A list of Labels this metric has.
- To add a comment to a metric, click Add comment.
- A link to open the Telemetry Usage Analyzer.
-
To add Filters, click the No filters box. A filter is a Label and Value pair that selects a subset of the data. Click the check icon to add the filter. You can add multiple filters.
-
In the Aggregation menu, you will see options depending on the type of metric.
If you chose a gauge metric or a counter metric (cumulative counter or delta counter), select from the following options:
Sum
Average
Min
Max
If you chose a histogram metric (cumulative exponential histogram, delta exponential histogram, or classic histogram), select from the following options:
Percentile
Average
Count
Then, select the one or more labels to group by.
-
In the Rollup menu, you will see additional functions depending on the type of metric.
After you select a metric, the builder checks for type information. If the type is available, it applies the most appropriate Rollup option. If the type is not available, you’ll need to manually select an option.
Chronosphere recommends the following settings:
- Cumulative counter or cumulative exponential histogram: Use
rate
orincrease
. - Delta counter or delta exponential histogram: Use
sum_per_second
orsum_over_time
. - Gauge: Don’t use any of these functions.
- Cumulative counter or cumulative exponential histogram: Use
-
Click Run to run the query. If the graph is in a dashboard, the graph updates as you make changes.
For additional query options, see Time series chart queries.
Remove values
To clear any field, click close icon at the end of the field.
To reset to the default value, click the field value and then click Reset.