---
title: View and query your Prometheus data
source: https://docs.newrelic.com/docs/infrastructure/prometheus-integrations/view-query-data/view-query-your-prometheus-data
---

To query and visualize the metrics collected for your Prometheus OpenMetrics or remote write integration with New Relic, you can use [NRQL](https://docs.newrelic.com/docs/query-data/nrql-new-relic-query-language/getting-started/nrql-syntax-components-functions). You can also [translate your PromQL-style queries to NRQL](https://docs.newrelic.com/docs/integrations/prometheus-integrations/view-query-data/translate-promql-queries-nrql) using either Grafana or the [query builder](https://docs.newrelic.com/docs/query-your-data/explore-query-data/query-builder/use-advanced-promql-style-mode-query-data).

All metrics for Docker and Kubernetes are stored in the `Metric` type.

## Default attributes for the OpenMetrics integration [#default-attributes]

By default, the following attributes will be added to all metrics for Docker and Kubernetes integrations:

| Default attributes                                           (all integrations) | Description                                                     |
| ------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| `clusterName`                                                                   | The name of the cluster provided in the scraper configuration.  |
| `integrationName`                                                               | The name of this integration (`nri-prometheus`).                |
| `integrationVersion`                                                            | The version of the integration; for example, `0.2.0`.           |
| `metricName`                                                                    | The name of the metric itself.                                  |
| `nrMetricType`                                                                  | The type of the New Relic `Metric` type; for example, `Gauges`. |
| `promMetricType`                                                                | The metric type of the Prometheus metric                        |
| `scrapedEndpoint`                                                               | The URL of the endpoint is being scraped.                       |

![img-integration-k8.png](https://docs.newrelic.com/images/os_icon_k8.webp "img-integration-k8.png") **Kubernetes:** If the scraper is running in Kubernetes, New Relic also adds the following attributes to all the metrics:

| Additional Kubernetes attributes | Description                                                               |
| -------------------------------- | ------------------------------------------------------------------------- |
| `deploymentName`                 | Name of the deployment, if scraping a pod.                                |
| `label`                          | The Kubernetes labels of the object being scraped, prefixed by `"label"`. |
| `namespaceName`                  | Name of the namespace.                                                    |
| `nodeName`                       | Name of the node where the pod being scraped is running, if applicable.   |
| `podName`                        | Name of the pod being scraped, if applicable.                             |
| `serviceName`                    | Name of the service being scraped, if applicable                          |

## Default attributes for the remote write integration [#default-attributes-remote-write]

By default, the following attributes will be added to Prometheus remote write metrics:

| Default attributes                                           (all integrations) | Description                                                                                                                                                                                                                 |
| ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `prometheus_server`                                                             | A user supplied label specified as a Prometheus remote write URL parameter. The value supplied should be unique as it is intended to differentiate between source Prometheus servers at query time. Unspecified by default. |
| `newrelic.source`                                                               | The name of the New Relic ingest point (`prometheusAPI`).                                                                                                                                                                   |
| `instrumentation.provider`                                                      | `prometheus`                                                                                                                                                                                                                |
| `instrumentation.name`                                                          | `remote-write`                                                                                                                                                                                                              |
| `instrumentation.source`                                                        | A user supplied identifier for the source of the Prometheus data that matches the value of `prometheus_server`.                                                                                                             |
| `instrumentation.version`                                                       | Used to identify the version of the remote write API; for example, `0.0.1.`                                                                                                                                                 |

## NRQL query examples [#nrql-examples]

When you [build queries](https://docs.newrelic.com/docs/query-your-data/explore-query-data/query-builder/use-advanced-nrql-mode-specify-data), be aware that there is no linking between the metrics, entities, and attributes. Use the following NRQL queries to find out which metrics are available and which attributes are present on these metrics:

**Get metric names**

To get all metric names for OpenMetrics:

````sql
FROM Metric SELECT uniques(metricName)
```

To get metric names for a remote write integration:

```sql
FROM Metric SELECT uniques(metricName) WHERE instrumentation.provider='prometheus' 
AND instrumentation.name='remote-write'
```

To get metric names for a remote write integration from a single Prometheus source:

```sql
FROM Metric SELECT uniques(metricName) WHERE instrumentation.provider='prometheus' 
AND instrumentation.name='remote-write' AND instrumentation.source='<ds>'
```

To get metric names for a specific OpenMetrics endpoint:

```sql
FROM Metric SELECT uniques(metricName) WHERE scrapedEndpoint='<ep>'
```

To get metric names for a specific OpenMetrics cluster, namespace, or pod:

```sql
FROM Metric SELECT uniques(metricName) WHERE clusterName='<cn>'
```

```sql
FROM Metric SELECT uniques(metricName) WHERE namespaceName='<ns>'
```

```sql
FROM Metric SELECT uniques(metricName) WHERE podName='<pod>'
```

````

**Get the attributes for a metric**

To get all attributes for the selected metric:

````sql
FROM Metric SELECT keyset() WHERE metricName='<mn>'
```

````

**Get the values for an attribute in OpenMetrics**

The autocomplete will show all values of the attribute, regardless of the pod. To determine the attribute values for a specific pod:

````sql
FROM Metric SELECT uniques(<attribute>) WHERE metricName='<mn>' AND podName='<pod>'
```

````

For more information about facets, time series, and time selection, see the [NRQL documentation](https://docs.newrelic.com/docs/query-data/nrql-new-relic-query-language/getting-started/nrql-syntax-components-functions).

## Build the query [#build-query]

To build PromQL-style queries, see our documentation about [supported PromQL features](https://docs.newrelic.com/docs/integrations/prometheus-integrations/view-query-data/supported-promql-features).

**Get metric values**

To get raw metric values:

````sql
FROM Metric SELECT <metricName> WHERE <attribute>='<value>'
```

````

**Get a chart of the metric**

To get a chart of the metric with an aggregator of `average`, `min`, `max`, or `sum`:

````sql
FROM Metric SELECT <aggregator>(<metricname>) WHERE <attribute>='<value>' TIMESERIES
```

````

**Query counter metrics (deltas)**

Currently the integration calculates the deltas for counter metrics. This is why queries on counter metrics will show the deltas of the counter instead of the absolute value of the counter.

**View connected Redis clients per pod with OpenMetrics**

![Docker icon](https://docs.newrelic.com/images/os_icon_docker.webp "Docker icon") **Docker:** This example assumes you are scraping Redis exporters. To view the number of connected Redis clients per endpoint in a cluster:

````sql
FROM Metric SELECT latest(redis_connected_clients) WHERE clusterName='my-cluster' 
FACET scrapedEndpoint TIMESERIES
```

<img style={{ width: '40px', height: '35px'}} class="inline" title="Kubernetes icon" alt="Kubernetes icon" src="/images/os_icon_k8.webp"/> <DNT>**Kubernetes:**</DNT> This example assumes that you have Redis pods with the Redis exporter installed. To view the number of connected Redis clients per pod in the default namespace:

```sql
FROM Metric SELECT latest(redis_connected_clients) WHERE namespaceName='default' FACET podName TIMESERIES
```

````

**Docker: View average memory free for scraped endpoints**

This example assumes you are scraping node exporters for Docker and want to use OpenMetrics. To view average memory free for all scraped endpoints in a cluster:

````sql
FROM Metric SELECT average(node_memory_MemFree_bytes) WHERE clusterName='my-cluster'
```

````

** Kubernetes: View average memory usage for pods in a deployment**

To view average memory usage for all pods in a Kubernetes deployment using OpenMetrics:

````sql
FROM Metric SELECT average(container_memory_usage_bytes) 
WHERE deploymentName='my-app-deployment' AND namespaceName='default'
```

````

## View data in New Relic [#view-ui]

When you query the data, you can view the results in the New Relic UI. You can also visualize the data as charts, histograms, etc.

To view the NRQL query results for your Prometheus integration's data:

1.  In New Relic, expand the query builder by clicking the bar at the bottom.
2.  Open the query builder menu by clicking the three dots next to the Copy your query link action, and then select PromQL.
3.  In the translator, enter your PromQL query. It's auto-translated into an NRQL query.
4.  Click **Submit**.

For more information, see our [query builder documentation](https://docs.newrelic.com/docs/chart-builder/use-chart-builder/get-started/introduction-chart-builder).

## Generate histograms and calculate percentiles [#histograms-percentiles]

Using Prometheus remote write or version [2.0.0](https://github.com/newrelic/nri-prometheus/blob/main/CHANGELOG.md#200) and higher of the Prometheus OpenMetrics Integration (POMI), you can generate histograms and calculate percentiles from your data. For Prometheus histograms, a bucket `<basename>_bucket{le="42"}` will be sent as the metric `<basename>_bucket`, and the dimension will be `{histogram.bucket.le="42"}`.

NRQL has two functions that work on Prometheus histograms ingested via remote write or the Prometheus OpenMetrics Integration (starting with version [2.0.0](https://github.com/newrelic/nri-prometheus/blob/main/CHANGELOG.md#200)): [`bucketPercentile()`](https://docs.newrelic.com/docs/query-your-data/nrql-new-relic-query-language/get-started/nrql-syntax-clauses-functions#func-bucket-percentile), and [`histogram()`](https://docs.newrelic.com/docs/query-your-data/nrql-new-relic-query-language/get-started/nrql-syntax-clauses-functions#func-histogram). The links include query examples.
