---
title: Configure New Relic as a Prometheus data source for Grafana
source: https://docs.newrelic.com/docs/query-your-data/grafana-integrations/set-configure/configure-new-relic-prometheus-data-source-grafana
---

You can configure a [Prometheus data source](https://grafana.com/docs/grafana/latest/features/datasources/prometheus/) in [Grafana](https://grafana.com/login) to query data stored in the New Relic Database (NRDB) using our [PromQL-style query language](https://docs.newrelic.com/docs/integrations/prometheus-integrations/view-query-data/supported-promql-features).

## Add a Prometheus data source [#create-update]

Follow these steps to add New Relic as a Prometheus data source for Grafana. These instructions detail how to complete the process when working with Grafana versions 6.7 and higher.

> #### ⚠️ IMPORTANT
>
> You must [complete the Prometheus remote-write integration](https://docs.newrelic.com/docs/integrations/prometheus-integrations/install-configure/set-your-prometheus-remote-write-integration) process prior to beginning the configuration process.

1.  In New Relic, [create a new Insights query key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#insights-query-key).

    > #### ⚠️ IMPORTANT
    >
    > In Grafana, you'll need put this in a custom **X-Query-Key** HTTP header (see step 7 below), but it is the same entity as the New Relic Query key.
    >
    > If your account is in the **JP region**, Insights query keys are not supported. Create a [User API Key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#user-key) instead, and use it with the **api-key** header in step 7.
2.  From the [Grafana](https://grafana.com/login) **Home** screen, go to **Configuration > Data Sources** and click **Add data source**.
3.  From the **Add data source** screen under **Time series databases** options, select **Prometheus**.
4.  Enter the **Name** you want to use for your new Prometheus data source.
5.  Set the **Default** toggle to the on or off position, depending on whether you want this to be your default data source for Prometheus queries.
    -   Off: this is not your default data source
    -   On: this is your default data source
6.  Enter the correct **URL**:
    -   US (default): [prometheus-api.newrelic.com](https://prometheus-api.newrelic.com)
    -   EU: [prometheus-api.eu.newrelic.com](https://prometheus-api.eu.newrelic.com)
    -   JP: [prometheus-api.jp.newrelic.com](https://prometheus-api.jp.newrelic.com)
7.  Under **Custom Headers**, select **Add Header**. For US and EU accounts, set the **Header** name to **X-Query-Key** and enter the Insights query key from step 1. For JP accounts, set the **Header** name to **api-key** and enter the User API Key from step 1.
8.  Click **Save & Test**.

> #### 💡 TIP
>
> If your graphs appear as groupings of dots and not as connected lines, you can change the graph style to display lines instead. To do this, go to Grafana's **[Graph panel](https://grafana.com/docs/grafana/latest/panels/visualizations/graph-panel/)** and select **Stacking and null value > connected**.

**Sample configuration image**

![Screen capture of the add data source workflow in Grafana](https://docs.newrelic.com/images/more-integrations_screenshot-crop_grafana-data-source-config.webp "Configure New Relic as a Prometheus data source for Grafana")

Grafana Data Source Config.png, by [dbarnesbrown.newrelic.com](/users/dbarnesbrownnewreliccom)

## Versioning considerations

New Relic strongly recommends using versions 6.7.x and higher to configure New Relic as a Prometheus data source. If you do chose to complete the configuration while running an earlier version, you will need to do one of the following to successfully configure your data source:

-   Configure the new data source to use basic authentication and then enter the Query-key as the password in the basic authentication workflow.
-   Configure the new data source URL to include the Query-key: `` https://prometheus-api.newrelic.com/auth/`<query-key>` ``

## Customize Prometheus API behavior [#customize-API]

Headers are particularly important if you have connected multiple Prometheus servers to New Relic using the [remote write integration](https://docs.newrelic.com/docs/integrations/prometheus-integrations/install-configure/set-your-prometheus-remote-write-integration). Here are some details about customization.

**X-Query-Key (Query key)**

The [Query key](https://docs.newrelic.com/docs/apis/get-started/intro-apis/types-new-relic-api-keys#x-query-key) parameter is required to authenticate with New Relic and identify the account containing your metrics. Grafana calls this an **X-Query key**, while it appears as a **Query key** in the New Relic UI.

Details:

-   Required
-   An API query key used for authentication
-   If you are using the Prometheus remote write integration, the X-Query-Key should correspond to the same account as the X-License-Key used to integrate for remote write

    **JP region exception**: The JP region does not support Insights query keys. Use a [User API Key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#user-key) with the header name **api-key** instead of **X-Query-Key**.

**X-Prometheus-Only**

> #### ⚠️ IMPORTANT
>
> Grafana's auto-complete support doesn't handle metrics that fail to strictly conform to Prometheus naming conventions. New Relic recommends you exclude any metrics that do not conform from this parameter.

Details:

-   Optional
-   Limits metrics exposed by the API to those originating from Prometheus
-   Default = true if not specified

**X-Prometheus-Server**

This parameter is useful if you are collecting metrics from multiple Prometheus servers. For example, if you are using Grafana, you might want to create a data source for each Prometheus server connected to New Relic and then another data source that can be used to query across all Prometheus servers.

Details:

-   Optional
-   Limits metrics exposed by the API to those collected from the specified Prometheus server
-   This value should match the `prometheus_server` URL parameter in the remote write URL used to connect to your prometheus server to New Relic
-   Defaults to return metrics collected from all servers

## Delete a Prometheus data source [#delete]

To delete a data source in Grafana:

1.  Go to **Configuration > Data Sources**.
2.  Click on the data source you want to delete.
3.  Click the **Delete** button at the bottom of the page.
