Are you familiar with PromQL or have a PromQL query you’d like to convert to NRQL? This document provides examples that show you how to convert some common PromQL queries to NRQL queries. You can use NRQL to simulate PromQL, and query your Prometheus OpenMetrics integration data with other data sent to New Relic.
Prometheus and New Relic metric types
The different metric types supported by Prometheus and New Relic are related to each other:
The Prometheus counter is a cumulative sum while the New Relic count is a delta sum.
For example, if you see 2 requests in the first reporting period and 3 requests in the second reporting period. The Prometheus counter will report 2 and then 5, while the New Relic count will report 2 and then 3.
|Gauge||Gauge||A Prometheus gauge is similar to a New Relic gauge.|
|Multiple counts||Histogram||Prometheus automatically maps a histogram to a set of counters. In New Relic, these counters should be changed to deltas and reported as counts.|
|Gauges and counts||Summary||Prometheus automatically maps a summary to a set of counters and gauges. These can be translated to New Relic counts and gauges.|
|Summary||(No equivalent in Prometheus)||New Relic has a distinct metric type called a summary that is different than the Prometheus summary. It is designed for reporting aggregated discrete events so that you can query the count, sum, min, max, and average values.|
Mapping between PromQL and NRQL
This table shows the mapping between PromQL and NRQL when exploring data. For more contextual information, see the examples.
|Description||Mapping between PromQL and NRQL|
Search for attributes:
Explore the attributes on the
Find attribute's value:
Explore the current value of the
Visualize the attribute's value:
Chart the value of the
- PromQL query example
1. Start your query.
When exploring your data for a particular metric in PromQL, such as memory by container usage in bytes, you can start with a query such as:
This will chart all the unique metric timeseries for the input metric.
2. Filter the query results.
Looking at the data, you can add more query parameters to filter down the number of metric timeseries. For example, if you only want timeseries where the
/, the PromQL query will be:
- NRQL query example
1. Query available metrics.
To explore your data, start by looking at all the available metrics. Use the following NRQL query:
FROM Metric SELECT uniques(metricName)
2. Find unique attributes.
Once you have found the metric you want to review, such as
container_memory_usage_bytes, you can find the unique attributes with the following query:
FROM Metric SELECT keyset() WHERE metricName = 'container_memory_usage_bytes'
The results will show each available attribute key and the value type (string, boolean, or number).
3. Aggregate and chart the metrics.
To chart metrics using NRQL, you first need an aggregation function. For example, you can use
sumfor counts, and
As the following chart shows, all the unique timeseries are aggregated into one unique timeseries by default:
4. View metrics by ID.
To view the unique metric timeseries with various
idvalues, run the following query:
FROM Metric SELECT latest(container_memory_usage_bytes) FACET id
5. Add the selected ID to the query.
Next you can select an
idvalue and put it in the NRQL
FROM Metric SELECT latest(container_memory_usage_bytes) WHERE id = "/" timeseries
Both PromQL and NRQL provide syntax to filter down the number of unique metric timeseries.
- PromQL uses brackets to filter.
- NRQL uses a
Here are some example queries:
|Description||PromQL and NRQL queries|
Select data with specific values.
Select data with multiple values.
Select data using partial string values.
PromQL to NRQL query examples
You can simulate the following PromQL queries with NRQL queries:
|Description||PromQL and NRQL queries|
|Measure the per second rate over the last minute of the
|Chart the difference of the two metrics, then divide by 1024.||
|Provide the summed rate per 30-second interval by each handler.||
|Chart the difference in the two metrics where the instance is named