Docs: Added new configure prometheus file, update index file (#70845)
* added config prometheus doc * updated index file * updated fundamentals exemplars doc validator issue
This commit is contained in:
@@ -14,14 +14,22 @@ weight: 1300
|
||||
|
||||
# Prometheus data source
|
||||
|
||||
Grafana ships with built-in support for Prometheus.
|
||||
This topic explains options, variables, querying, and other features specific to the Prometheus data source, which include its [feature-rich code editor for queries and visual query builder]({{< relref "./query-editor/" >}}).
|
||||
Prometheus is an open-source database that uses an 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?]({{< relref "../../fundamentals/intro-to-prometheus/" >}}).
|
||||
|
||||
Grafana provides native support for Prometheus.
|
||||
For instructions on downloading Prometheus see [Get started with Grafana and Prometheus](/docs/grafana/latest/getting-started/get-started-grafana-prometheus/#get-started-with-grafana-and-prometheus).
|
||||
|
||||
For instructions on how to add a data source to Grafana, refer to the [administration documentation]({{< relref "../../administration/data-source-management/" >}}).
|
||||
Only users with the organization administrator role can add data sources.
|
||||
Only users with the organization `administrator` role can add data sources and edit existing data sources.
|
||||
Administrators can also [configure the data source via YAML]({{< relref "#provision-the-data-source" >}}) with Grafana's provisioning system.
|
||||
|
||||
Once you've added the data source, you can [configure it]({{< relref "#configure-the-data-source" >}}) so that your Grafana instance's users can create queries in its [query editor]({{< relref "./query-editor/" >}}) when they [build dashboards]({{< relref "../../dashboards/build-dashboards/" >}}), use [Explore]({{< relref "../../explore/" >}}), and [annotate visualizations]({{< relref "./query-editor/#apply-annotations" >}}).
|
||||
Once you've added the Prometheus data source, you can [configure it](/docs/grafana/latest/datasources/prometheus/configure-prometheus-data-source/) so that your Grafana instance's users can create queries in its [query editor]({{< relref "./query-editor/" >}}) when they [build dashboards]({{< relref "../../dashboards/build-dashboards/" >}}), use [Explore]({{< relref "../../explore/" >}}), and [annotate visualizations]({{< relref "./query-editor/#apply-annotations" >}}).
|
||||
|
||||
The following guides will help you get started with the Prometheus data source:
|
||||
|
||||
- [Configure the Prometheus data source](/docs/grafana/latest/datasources/prometheus/configure-prometheus-data-source/)
|
||||
- [Prometheus query editor](/docs/grafana/latest/datasources/prometheus/query-editor/)
|
||||
- [Template variables](/docs/grafana/latest/datasources/prometheus/template-variables/)
|
||||
|
||||
## Prometheus API
|
||||
|
||||
@@ -32,81 +40,47 @@ For more information on how to query other Prometheus-compatible projects from G
|
||||
- [Grafana Mimir](/docs/mimir/latest/)
|
||||
- [Thanos](https://thanos.io/tip/components/query.md/)
|
||||
|
||||
## Configure the data source
|
||||
|
||||
To configure basic settings for the data source, complete the following steps:
|
||||
|
||||
1. Click **Connections** in the left-side menu.
|
||||
1. Under Your connections, click **Data sources**.
|
||||
1. Enter `Prometheus` in the search bar.
|
||||
1. Select **Prometheus**.
|
||||
|
||||
The **Settings** tab of the data source is displayed.
|
||||
|
||||
1. Set the data source's basic configuration options:
|
||||
|
||||
| Name | Description |
|
||||
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `Name` | The data source name. This is how you refer to the data source in panels and queries. |
|
||||
| `Default` | Default data source that is pre-selected for new panels. |
|
||||
| `URL` | The URL of your Prometheus server, for example, `http://prometheus.example.org:9090`. |
|
||||
| `Access` | Only Server access mode is functional. If Server mode is already selected this option is hidden. Otherwise change to Server mode to prevent errors. |
|
||||
| `Basic Auth` | Enable basic authentication to the Prometheus data source. |
|
||||
| `User` | User name for basic authentication. |
|
||||
| `Password` | Password for basic authentication. |
|
||||
| `Manage alerts via Alerting UI` | Toggle whether to enable Alertmanager integration for this data source. |
|
||||
| `Scrape interval` | Set this to the typical scrape and evaluation interval configured in Prometheus. Defaults to 15s. |
|
||||
| `HTTP method` | Use either POST or GET HTTP method to query your data source. POST is the recommended and pre-selected method as it allows bigger queries. Change this to GET if you have a Prometheus version older than 2.1 or if POST requests are restricted in your network. |
|
||||
| `Type` | The type of your Prometheus server; `Prometheus`, `Cortex`, `Thanos`, `Mimir`. When selected, the **Version** field attempts to populate automatically using the Prometheus [buildinfo](https://semver.org/) API. Some Prometheus types, such as Cortex, don't support this API and must be manually populated. |
|
||||
| `Version` | The version of your Prometheus server, note that this field is not visible until the Prometheus type is selected. |
|
||||
| `Disable metrics lookup` | Checking this option will disable the metrics chooser and metric/label support in the query field's autocomplete. This helps if you have performance issues with bigger Prometheus instances. |
|
||||
| `Custom query parameters` | Add custom parameters to the Prometheus query URL. For example `timeout`, `partial_response`, `dedup`, or `max_source_resolution`. Multiple parameters should be concatenated together with an '&'. |
|
||||
|
||||
**Exemplars configuration:**
|
||||
|
||||
| Name | Description |
|
||||
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| **Internal link** | Enable this option if you have an internal link. When enabled, this reveals the data source selector. Select the backend tracing data store for your exemplar data. |
|
||||
| **Data source** | _(Visible only if you enable `Internal link`)_ Selects the backend tracing data store for your exemplar data. |
|
||||
| **URL** | _(Visible only if you disable `Internal link`)_ Defines the external link's full URL. You can interpolate the value from the field by using the [`${__value.raw}` macro]({{< relref "../..//panels-visualizations/configure-data-links/#value-variables" >}}). |
|
||||
| **URL label** | _(Optional)_ Adds a custom display label to override the value of the `Label name` field. |
|
||||
| **Label name** | Adds a name for the exemplar traceID property. |
|
||||
|
||||
### Provision the data source
|
||||
## Provision the data source
|
||||
|
||||
You can define and configure the data source in YAML files as part of Grafana's provisioning system.
|
||||
For more information about provisioning, and for available configuration options, refer to [Provisioning Grafana]({{< relref "../../administration/provisioning/#data-sources" >}}).
|
||||
|
||||
#### Provisioning example
|
||||
{{% admonition type="note" %}}
|
||||
Once you have provisioned a data source you cannot edit it.
|
||||
{{% /admonition %}}
|
||||
|
||||
### Provisioning example
|
||||
|
||||
```yaml
|
||||
apiVersion: 1
|
||||
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
type: prometheus
|
||||
# Access mode - proxy (server in the UI) or direct (browser in the UI).
|
||||
access: proxy
|
||||
url: http://localhost:9090
|
||||
jsonData:
|
||||
httpMethod: POST
|
||||
manageAlerts: true
|
||||
prometheusType: Prometheus
|
||||
prometheusVersion: 2.37.0
|
||||
incrementalQuerying: true
|
||||
incrementalQueryOverlapWindow: 10m
|
||||
cacheLevel: 'High'
|
||||
incrementalQuerying: true
|
||||
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'
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
type: prometheus
|
||||
# Access mode - proxy (server in the UI) or direct (browser in the UI).
|
||||
access: proxy
|
||||
url: http://localhost:9090
|
||||
jsonData:
|
||||
httpMethod: POST
|
||||
manageAlerts: true
|
||||
prometheusType: Prometheus
|
||||
prometheusVersion: 2.44.0
|
||||
incrementalQuerying: true
|
||||
incrementalQueryOverlapWindow: 10m
|
||||
cacheLevel: 'High'
|
||||
incrementalQuerying: true
|
||||
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'
|
||||
```
|
||||
|
||||
## View Grafana metrics with Prometheus
|
||||
@@ -119,13 +93,13 @@ We also bundle a dashboard within Grafana so you can start viewing your metrics
|
||||
1. Navigate to the data source's [configuration page]({{< relref "#configure-the-data-source" >}}).
|
||||
1. Select the **Dashboards** tab.
|
||||
|
||||
This displays dashboards for Grafana and Prometheus.
|
||||
This displays dashboards for Grafana and Prometheus.
|
||||
|
||||
1. Select **Import** for the dashboard to import.
|
||||
|
||||
For details about these metrics, refer to [Internal Grafana metrics]({{< relref "../../setup-grafana/set-up-grafana-monitoring/" >}}).
|
||||
|
||||
### Amazon Managed Service for Prometheus
|
||||
## Amazon Managed Service for Prometheus
|
||||
|
||||
The Prometheus data source works with Amazon Managed Service for Prometheus.
|
||||
|
||||
@@ -133,7 +107,7 @@ If you use an AWS Identity and Access Management (IAM) policy to control access
|
||||
|
||||
For details on AWS SigV4, refer to the [AWS documentation](https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html).
|
||||
|
||||
#### AWS Signature Version 4 authentication
|
||||
### AWS Signature Version 4 authentication
|
||||
|
||||
{{% admonition type="note" %}}
|
||||
Available in Grafana v7.3.5 and higher.
|
||||
@@ -143,39 +117,27 @@ To connect the Prometheus data source to Amazon Managed Service for Prometheus u
|
||||
|
||||
If you run Grafana in an Amazon EKS cluster, follow the AWS guide to [Query using Grafana running in an Amazon EKS cluster](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-onboard-query-grafana-7.3.html).
|
||||
|
||||
### Configure exemplars
|
||||
## Exemplars
|
||||
|
||||
Exemplars associate higher-cardinality metadata from a specific event with traditional time series data. See [Introduction to exemplars]({{< relref "../../fundamentals/exemplars/" >}}) in Prometheus documentation for detailed information on how they work.
|
||||
|
||||
{{% admonition type="note" %}}
|
||||
Available in Prometheus v2.26 and higher with Grafana v7.4 and higher.
|
||||
{{% /admonition %}}
|
||||
|
||||
Grafana 7.4 and higher can show exemplars data alongside a metric both in Explore and in Dashboards.
|
||||
Exemplars associate higher-cardinality metadata from a specific event with traditional time series data.
|
||||
|
||||
{{< figure src="/static/img/docs/v74/exemplars.png" class="docs-image--no-shadow" caption="Screenshot showing the detail window of an Exemplar" >}}
|
||||
|
||||
Configure Exemplars in the data source settings by adding external or internal links.
|
||||
See the Exemplars section in [Configure Prometheus data source](/docs/grafana/latest/datasources/prometheus/configure-prometheus-data-source/).
|
||||
|
||||
{{< figure src="/static/img/docs/v74/exemplars-setting.png" class="docs-image--no-shadow" caption="Screenshot of the Exemplars configuration" >}}
|
||||
{{< figure src="/static/img/docs/prometheus/exemplars-10-1.png" max-width="500px" class="docs-image--no-shadow" caption="Exemplars" >}}
|
||||
|
||||
## Query the data source
|
||||
|
||||
You can create queries with the Prometheus data source's query editor.
|
||||
|
||||
For details, refer to the [query editor documentation]({{< relref "./query-editor/" >}}).
|
||||
|
||||
## Use template variables
|
||||
|
||||
Instead of hard-coding details such as server, application, and sensor names in metric queries, you can use variables.
|
||||
Grafana lists these variables in dropdown select boxes at the top of the dashboard to help you change the data displayed in your dashboard.
|
||||
Grafana refers to such variables as template variables.
|
||||
|
||||
For details, see the [template variables documentation]({{< relref "./template-variables/" >}}).
|
||||
|
||||
## Incremental Dashboard Queries (beta)
|
||||
## Incremental dashboard queries (beta)
|
||||
|
||||
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.
|
||||
This can be toggled on or off in the datasource 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).
|
||||
|
||||
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).
|
||||
|
||||
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.
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
---
|
||||
aliases:
|
||||
- ../data-sources/prometheus/
|
||||
- ../features/datasources/prometheus/
|
||||
description: Guide for configuring Prometheus in Grafana
|
||||
keywords:
|
||||
- grafana
|
||||
- prometheus
|
||||
- guide
|
||||
menuTitle: Configure Prometheus
|
||||
title: Configure the Prometheus data source
|
||||
weight: 200
|
||||
---
|
||||
|
||||
# Configure Prometheus
|
||||
|
||||
Grafana ships with built-in support for Prometheus. If you are new to Prometheus the following documentation will help you get started working with Prometheus and Grafana:
|
||||
|
||||
- [What is Prometheus?]({{< relref "../../fundamentals/intro-to-prometheus/" >}})
|
||||
- [Prometheus data model](https://prometheus.io/docs/concepts/data_model/)
|
||||
- [Getting started](https://prometheus.io/docs/prometheus/latest/getting_started/)
|
||||
|
||||
## Configure the data source
|
||||
|
||||
To add the Prometheus data source, complete the following steps:
|
||||
|
||||
1. Click **Connections** in the left-side menu.
|
||||
1. Under **Connections**, click **Add new connection**.
|
||||
1. Enter `Prometheus` in the search bar.
|
||||
1. Select **Prometheus data source**.
|
||||
1. Click **Create a Prometheus data source** in the upper right.
|
||||
|
||||
You will be taken to the **Settings** tab where you will set up your Prometheus configuration.
|
||||
|
||||
## Configuration options
|
||||
|
||||
The following is a list of configuration options for Prometheus.
|
||||
|
||||
The first option to configure is the name of your connection:
|
||||
|
||||
- **Name** - The data source name. This is how you refer to the data source in panels and queries. Examples: prometheus-1, prom-metrics.
|
||||
|
||||
- **Default** - Toggle to select as the default name in dashboard panels. When you go to a dashboard panel this will be the default selected data source.
|
||||
|
||||
### HTTP section
|
||||
|
||||
- **URL** - The URL of your Prometheus server. If your Prometheus server is local, use `<http://localhost:9090>`. If it is on a server within a network, this is the URL with port where you are running Prometheus. Example: `<http://prometheus.example.orgname:9090>`.
|
||||
|
||||
- **Allowed cookies** - Specify cookies by name that should be forwarded to the data source. The Grafana proxy deletes all forwarded cookies by default.
|
||||
|
||||
- **Timeout** - The HTTP request timeout. This must be in seconds. There is no default, so this setting is up to you.
|
||||
|
||||
### Auth section
|
||||
|
||||
There are several authentication methods you can choose in the Authentication section.
|
||||
|
||||
{{% admonition type="note" %}}
|
||||
|
||||
Use TLS (Transport Layer Security) for an additional layer of security when working with Prometheus. For information on setting up TLS encryption with Prometheus see [Securing Prometheus API and UI Endpoints Using TLS Encryption](https://prometheus.io/docs/guides/tls-encryption/). You must add TLS settings to your Prometheus configuration file **prior** to setting these options in Grafana.
|
||||
|
||||
{{% /admonition %}}
|
||||
|
||||
- **Basic authentication** - The most common authentication method. Use your `data source` user name and `data source` password to connect.
|
||||
|
||||
- **With credentials** - Toggle on to enable credentials such as cookies or auth headers to be sent with cross-site requests.
|
||||
|
||||
- **TLS client authentication** - Toggle on to use client authentication. When enabled, add the `Server name`, `Client cert` and `Client key`. The client provides a certificate that is validated by the server to establish the client's trusted identity. The client key encrypts the data between client and server.
|
||||
|
||||
- **With CA cert** - Authenticate with a CA certificate. Follow the instructions of the CA (Certificate Authority) to download the certificate file.
|
||||
|
||||
- **Skip TLS verify** - Toggle on to bypass TLS certificate validation.
|
||||
|
||||
- **Forward OAuth identity** - Forward the OAuth access token (and also the OIDC ID token if available) of the user querying the data source.
|
||||
|
||||
### Custom HTTP headers
|
||||
|
||||
- **Header** - Add a custom header. This allows custom headers to be passed based on the needs of your Prometheus instance.
|
||||
|
||||
- **Value** - The value of the header.
|
||||
|
||||
## Additional settings
|
||||
|
||||
Following are additional configuration options.
|
||||
|
||||
### Alerting
|
||||
|
||||
- **Manage alerts via Alerting UI** - Toggle to enable `Alertmanager` integration for this data source.
|
||||
|
||||
### Interval behavior
|
||||
|
||||
- **Scrape interval** - Set this to the typical scrape and evaluation interval configured in Prometheus. The default is `15s`.
|
||||
|
||||
- **Query timeout** - The default is `60s`.
|
||||
|
||||
### Query editor
|
||||
|
||||
- **Default editor** - Sets a default editor. Options are `Builder` or `Code`. For information on query editor types see [Prometheus query editor](/docs/grafana/latest/datasources/prometheus/query-editor/).
|
||||
|
||||
- **Disable metrics lookup** - Toggle on to disable the metrics chooser and metric/label support in the query field's autocomplete. This helps if you have performance issues with large Prometheus instances.
|
||||
|
||||
### Performance
|
||||
|
||||
- **Prometheus type** - The type of your Prometheus server. There are four options: `Prometheus`, `Cortex`, `Thanos`, `Mimir`.
|
||||
|
||||
- **Version** Select the version you are using. Once the Prometheus type has been selected, a list of versions auto-populates using the Prometheus [buildinfo](https://semver.org/) API. The `Cortex` Prometheus type does not support this API so you will need to manually add the version.
|
||||
|
||||
- **Incremental querying (beta)** - Changes the default behavior of relative queries to always request fresh data from the Prometheus instance. Enable this option to decrease database and network load.
|
||||
|
||||
### Other
|
||||
|
||||
- **Custom query parameters** - Add custom parameters to the Prometheus query URL. For example `timeout`, `partial_response`, `dedup`, or `max_source_resolution`. Multiple parameters should be concatenated together with an '&'.
|
||||
|
||||
- **HTTP method** - Use either `POST` or `GET` HTTP method to query your data source. `POST` is the recommended and pre-selected method as it allows bigger queries. Change to `GET` if you have a Prometheus version older than 2.1 or if `POST` requests are restricted in your network.
|
||||
|
||||
### Exemplars
|
||||
|
||||
Support for exemplars is available only for the Prometheus data source. If this is your first time working with exemplars see [Introduction to exemplars]({{< relref "../../fundamentals/exemplars/" >}}). An exemplar is a specific trace representative of measurement taken in a given time interval.
|
||||
|
||||
- **Internal link** - Toggle on to enable an internal link. When enabled, reveals the data source selector. Select the backend tracing data store for your exemplar data.
|
||||
|
||||
- **URL** - _(Visible if you **disable** `Internal link`)_ Defines the external link's URL trace backend. You can interpolate the value from the field by using the [`${__value.raw}` macro]({{< relref "../..//panels-visualizations/configure-data-links/#value-variables" >}}).
|
||||
|
||||
- **Data source** - _(Visible if you **enable** `Internal link`)_ The data source the exemplar will navigate to.
|
||||
|
||||
- **URL label** - Adds a custom display label to override the value of the `Label name` field.
|
||||
|
||||
- **Label name** - The name of the field in the `labels` object used to obtain the traceID property.
|
||||
|
||||
- **Remove exemplar link** - Click to remove existing links.
|
||||
Reference in New Issue
Block a user