2022-11-01 23:22:06 +08:00
---
aliases:
2022-12-10 00:36:04 +08:00
- ../data-sources/prometheus/
- ../features/datasources/prometheus/
2022-11-01 23:22:06 +08:00
description: Guide for using Prometheus in Grafana
keywords:
- grafana
- prometheus
- guide
Explicitly set all front matter labels in the source files (#71548)
* Set every page to have defaults of 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration pages to have of 'Cloud', 'Enterprise', and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/enterprise-licensing pages to have 'Enterprise' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/organization-management pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/provisioning pages to have 'Enterprise' and 'Open source' labels
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/recorded-queries pages to have labels cloud,enterprise
* Set administration/roles-and-permissions/access-control pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set administration/stats-and-license pages to have labels cloud,enterprise
* Set alerting pages to have labels cloud,enterprise,oss
* Set breaking-changes pages to have labels cloud,enterprise,oss
* Set dashboards pages to have labels cloud,enterprise,oss
* Set datasources pages to have labels cloud,enterprise,oss
* Set explore pages to have labels cloud,enterprise,oss
* Set fundamentals pages to have labels cloud,enterprise,oss
* Set introduction/grafana-cloud pages to have labels cloud
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Fix introduction pages products
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set panels-visualizations pages to have labels cloud,enterprise,oss
* Set release-notes pages to have labels cloud,enterprise,oss
* Set search pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/audit-grafana pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-authentication pages to have labels cloud,enterprise,oss
* Set setup-grafana/configure-security/configure-authentication/enhanced-ldap pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-authentication/saml pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-database-encryption/encrypt-secrets-using-hashicorp-key-vault pages to have labels cloud,enterprise
* Set setup-grafana/configure-security/configure-request-security pages to have labels cloud,enterprise,oss
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/configure-team-sync pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set setup-grafana/configure-security/export-logs pages to have labels cloud,enterprise
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
* Set troubleshooting pages to have labels cloud,enterprise,oss
* Set whatsnew pages to have labels cloud,enterprise,oss
* Apply updated labels from review
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
---------
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
2023-07-18 16:10:12 +08:00
labels:
products:
- cloud
- enterprise
- oss
2022-11-01 23:22:06 +08:00
menuTitle: Prometheus
title: Prometheus data source
weight: 1300
2024-05-28 22:17:49 +08:00
refs:
build-dashboards:
- pattern: /docs/grafana/
destination: /docs/grafana/< GRAFANA_VERSION > /dashboards/build-dashboards/
- pattern: /docs/grafana-cloud/
destination: /docs/grafana/< GRAFANA_VERSION > /dashboards/build-dashboards/
get-started-prometheus:
- pattern: /docs/grafana/
destination: /docs/grafana/< GRAFANA_VERSION > /getting-started/get-started-grafana-prometheus/#get-started-with-grafana-and-prometheus
- pattern: /docs/grafana-cloud/
destination: /docs/grafana/< GRAFANA_VERSION > /getting-started/get-started-grafana-prometheus/#get-started-with-grafana-and-prometheus
configure-grafana-configuration-file-location:
- pattern: /docs/grafana/
destination: /docs/grafana/< GRAFANA_VERSION > /setup-grafana/configure-grafana/#configuration-file-location
- pattern: /docs/grafana-cloud/
destination: /docs/grafana/< GRAFANA_VERSION > /setup-grafana/configure-grafana/#configuration-file-location
provisioning-data-sources:
- pattern: /docs/grafana/
destination: /docs/grafana/< GRAFANA_VERSION > /administration/provisioning/#data-sources
- pattern: /docs/grafana-cloud/
destination: /docs/grafana/< GRAFANA_VERSION > /administration/provisioning/#data-sources
explore:
- pattern: /docs/grafana/
destination: /docs/grafana/< GRAFANA_VERSION > /explore/
- pattern: /docs/grafana-cloud/
destination: /docs/grafana/< GRAFANA_VERSION > /explore/
set-up-grafana-monitoring:
- pattern: /docs/grafana/
destination: /docs/grafana/< GRAFANA_VERSION > /setup-grafana/set-up-grafana-monitoring/
- pattern: /docs/grafana-cloud/
destination: /docs/grafana/< GRAFANA_VERSION > /setup-grafana/set-up-grafana-monitoring/
configure-grafana:
- pattern: /docs/grafana/
destination: /docs/grafana/< GRAFANA_VERSION > /setup-grafana/configure-grafana/
- pattern: /docs/grafana-cloud/
destination: /docs/grafana/< GRAFANA_VERSION > /setup-grafana/configure-grafana/
administration-documentation:
- pattern: /docs/grafana/
destination: /docs/grafana/< GRAFANA_VERSION > /administration/data-source-management/
- pattern: /docs/grafana-cloud/
destination: /docs/grafana/< GRAFANA_VERSION > /administration/data-source-management/
annotate-visualizations:
- pattern: /docs/grafana/
destination: /docs/grafana/< GRAFANA_VERSION > /dashboards/build-dashboards/annotate-visualizations/
- pattern: /docs/grafana-cloud/
destination: /docs/grafana-cloud/visualizations/dashboards/build-dashboards/annotate-visualizations/
exemplars:
- pattern: /docs/grafana/
destination: /docs/grafana/< GRAFANA_VERSION > /fundamentals/exemplars/
- pattern: /docs/grafana-cloud/
destination: /docs/grafana/< GRAFANA_VERSION > /fundamentals/exemplars/
intro-to-prometheus:
- pattern: /docs/grafana/
destination: /docs/grafana/< GRAFANA_VERSION > /fundamentals/intro-to-prometheus/
- pattern: /docs/grafana-cloud/
destination: /docs/grafana/< GRAFANA_VERSION > /fundamentals/intro-to-prometheus/
configure-prometheus-data-source:
- pattern: /docs/grafana/
destination: /docs/grafana/< GRAFANA_VERSION > /datasources/prometheus/configure-prometheus-data-source/
- pattern: /docs/grafana-cloud/
destination: /docs/grafana/< GRAFANA_VERSION > /datasources/prometheus/configure-prometheus-data-source/
2022-11-01 23:22:06 +08:00
---
# Prometheus data source
2024-05-28 22:17:49 +08:00
Prometheus is an open-source database that uses a telemetry collector agent to scrape and store metrics used for monitoring and alerting. If you are just getting started with Prometheus, see [What is Prometheus? ](ref:intro-to-prometheus ).
2023-06-28 22:27:40 +08:00
Grafana provides native support for Prometheus.
2024-05-28 22:17:49 +08:00
For instructions on downloading Prometheus see [Get started with Grafana and Prometheus ](ref:get-started-prometheus ).
2022-11-01 23:22:06 +08:00
2024-05-28 22:17:49 +08:00
For instructions on how to add a data source to Grafana, refer to the [administration documentation ](ref:administration-documentation ).
2023-06-28 22:27:40 +08:00
Only users with the organization `administrator` role can add data sources and edit existing data sources.
2023-07-31 23:34:03 +08:00
Administrators can also [configure the data source via YAML ](#provision-the-data-source ) with Grafana's provisioning system.
2022-11-01 23:22:06 +08:00
2025-03-06 20:59:08 +08:00
Once you've added the Prometheus data source, you can [configure it ](ref:configure-prometheus-data-source ) so that your Grafana instance's users can create queries in its [query editor ](query-editor/ ) when they [build dashboards ](ref:build-dashboards ), use [Explore ](ref:explore ), and [annotate visualizations ](ref:annotate-visualizations ).
2023-06-28 22:27:40 +08:00
The following guides will help you get started with the Prometheus data source:
2024-05-28 22:17:49 +08:00
- [Configure the Prometheus data source ](ref:configure-prometheus-data-source )
2025-03-06 20:59:08 +08:00
- [Prometheus query editor ](query-editor/ )
- [Template variables ](template-variables/ )
2022-11-01 23:22:06 +08:00
## Prometheus API
The Prometheus data source also works with other projects that implement the [Prometheus querying API ](https://prometheus.io/docs/prometheus/latest/querying/api/ ).
For more information on how to query other Prometheus-compatible projects from Grafana, refer to the specific project's documentation:
- [Grafana Mimir ](/docs/mimir/latest/ )
- [Thanos ](https://thanos.io/tip/components/query.md/ )
2023-06-28 22:27:40 +08:00
## Provision the data source
2022-11-01 23:22:06 +08:00
You can define and configure the data source in YAML files as part of Grafana's provisioning system.
2024-05-28 22:17:49 +08:00
For more information about provisioning, and for available configuration options, refer to [Provisioning Grafana ](ref:provisioning-data-sources ).
2022-11-01 23:22:06 +08:00
2023-06-28 22:27:40 +08:00
{{% admonition type="note" %}}
Once you have provisioned a data source you cannot edit it.
{{% /admonition %}}
### Provisioning example
2022-11-01 23:22:06 +08:00
```yaml
apiVersion: 1
datasources:
2023-08-02 02:24:44 +08:00
- name: Prometheus
type: prometheus
access: proxy
# Access mode - proxy (server in the UI) or direct (browser in the UI).
url: http://localhost:9090
jsonData:
httpMethod: POST
manageAlerts: true
prometheusType: Prometheus
prometheusVersion: 2.44.0
cacheLevel: 'High'
disableRecordingRules: false
incrementalQueryOverlapWindow: 10m
exemplarTraceIdDestinations:
# Field with internal link pointing to data source in Grafana.
# datasourceUid value can be anything, but it should be unique across all defined data source uids.
- datasourceUid: my_jaeger_uid
name: traceID
# Field with external link.
- name: traceID
url: 'http://localhost:3000/explore?orgId=1& left=%5B%22now-1h%22,%22now%22,%22Jaeger%22,%7B%22query%22:%22$${__value.raw}%22%7D%5D'
2022-11-01 23:22:06 +08:00
```
## View Grafana metrics with Prometheus
Grafana exposes metrics for Prometheus on the `/metrics` endpoint.
We also bundle a dashboard within Grafana so you can start viewing your metrics faster.
**To import the bundled dashboard:**
2024-06-21 02:30:28 +08:00
1. Navigate to the data source's [configuration page ](ref:configure-prometheus-data-source ).
2022-11-01 23:22:06 +08:00
1. Select the **Dashboards** tab.
2024-10-15 01:23:48 +08:00
This displays dashboards for Grafana and Prometheus.
2022-11-01 23:22:06 +08:00
1. Select **Import** for the dashboard to import.
2024-05-28 22:17:49 +08:00
For details about these metrics, refer to [Internal Grafana metrics ](ref:set-up-grafana-monitoring ).
2022-11-01 23:22:06 +08:00
2023-06-28 22:27:40 +08:00
## Amazon Managed Service for Prometheus
2022-11-01 23:22:06 +08:00
2024-11-20 06:42:42 +08:00
The Prometheus data source with Amazon Managed Service for Prometheus is deprecated. Please use the [Amazon Managed service for Prometheus data source ](https://grafana.com/grafana/plugins/grafana-amazonprometheus-datasource/ ). Migrations steps are detailed in the link.
2022-11-01 23:22:06 +08:00
2023-07-18 21:16:36 +08:00
## Azure authentication settings
2023-07-21 00:39:59 +08:00
The Prometheus data source works with Azure authentication. To configure Azure authentication see [Configure Azure Active Directory (AD) authentication ](/docs/grafana/latest/datasources/azure-monitor/#configure-azure-active-directory-ad-authentication ).
2023-07-18 21:16:36 +08:00
2024-05-28 22:17:49 +08:00
In Grafana Enterprise, update the .ini configuration file: [Configure Grafana ](ref:configure-grafana ). Depending on your setup, the .ini file is located [here ](ref:configure-grafana-configuration-file-location ).
2023-07-18 21:16:36 +08:00
Add the following setting in the ** [auth]** section :
```bash
[auth]
azure_auth_enabled = true
```
{{% admonition type="note" %}}
If you are using Azure authentication settings do not enable `Forward OAuth identity` . Both use the same HTTP authorization headers. Azure settings will get overwritten by the Oauth token.
{{% /admonition %}}
2023-06-28 22:27:40 +08:00
## Exemplars
2024-05-28 22:17:49 +08:00
Exemplars associate higher-cardinality metadata from a specific event with traditional time series data. See [Introduction to exemplars ](ref:exemplars ) in Prometheus documentation for detailed information on how they work.
2022-11-01 23:22:06 +08:00
2023-05-23 04:45:28 +08:00
{{% admonition type="note" %}}
Available in Prometheus v2.26 and higher with Grafana v7.4 and higher.
{{% /admonition %}}
2022-11-01 23:22:06 +08:00
2024-10-24 22:42:04 +08:00
Grafana can show exemplars data alongside a metric both in Explore and in Dashboards.
2022-11-01 23:22:06 +08:00
{{< figure src = "/static/img/docs/v74/exemplars.png" class = "docs-image--no-shadow" caption = "Screenshot showing the detail window of an Exemplar" > }}
2024-05-28 22:17:49 +08:00
See the Exemplars section in [Configure Prometheus data source ](ref:configure-prometheus-data-source ).
2022-11-01 23:22:06 +08:00
2023-06-28 22:27:40 +08:00
{{< figure src = "/static/img/docs/prometheus/exemplars-10-1.png" max-width = "500px" class = "docs-image--no-shadow" caption = "Exemplars" > }}
2022-11-01 23:22:06 +08:00
2023-06-28 22:27:40 +08:00
## Incremental dashboard queries (beta)
2023-04-13 02:10:10 +08:00
As of Grafana 10, the Prometheus data source can be configured to query live dashboards incrementally, instead of re-querying the entire duration on each dashboard refresh.
2023-06-28 22:27:40 +08:00
This can be toggled on or off in the data source configuration or provisioning file (under `incrementalQuerying` in jsonData).
Additionally, the amount of overlap between incremental queries can be configured using the `incrementalQueryOverlapWindow` jsonData field, the default value is `10m` (10 minutes).
2023-04-13 02:10:10 +08:00
Increasing the duration of the `incrementalQueryOverlapWindow` will increase the size of every incremental query, but might be helpful for instances that have inconsistent results for recent data.
2023-06-29 23:58:22 +08:00
## Recording Rules (beta)
The Prometheus data source can be configured to disable recording rules under the data source configuration or provisioning file (under `disableRecordingRules` in jsonData).