Ingest metrics from Prometheus

Grafana Metrics Enterprise DocumentationGetting StartedIngest Metrics

Create Instance

First we starting by creating a instance (Cortex calls this tenant) for this demo:

  1. Navigate to Grafana Metrics Enterprise ≫ Instances.

  2. Click on Create new instance.

  3. Choose a name for this very instance. This guide will continue with the name demo.

  4. After selecting the cluster click on Create instance

Create Datasource Access Policy and Token

Now we create a access policy and a token, that is used by Grafana it self to access the time series data in the instance demo:

  1. Navigate to Grafana Metrics Enterprise ≫ Access Policies.

  2. Click on Create new access policy.

  3. Choose a name for the policy, this guides uses demo-grafana.

  4. Select the instance demo.

  5. Enable the scope read.

  6. Click on Create.

  7. Under the new access policy we just create we click on + Add token.

  8. We call the token demo-grafana again and click on Create.

  9. In the next window we make sure to copy the token into the clipboard.

Following that we can use this access policy and token to create a new datasource in Grafana:

  1. Navigate to Configuration ≫ Data Sources.

  2. Click on Add new data source.

  3. Select Prometheus.

  4. Set the URL to http://metrics-enterprise/api/prom.

  5. Enable Basic Auth and use User demo and as Password the token from your clipboard.

  6. Click Save & Test.

Create Prometheus Access Policy and Token

To be able to have some metrics inside our cluster we now create an access policy, so a Prometheus instance, can remote write time series into the instance demo:

  1. Navigate to Grafana Metrics Enterprise ≫ Access Policies.

  2. Click on Create new access policy.

  3. Choose a name for the policy, this guides uses demo-prometheus.

  4. Select the instance demo.

  5. Enable the scope write.

  6. Click on Create.

  7. Under the new access policy we just create we click on + Add token.

  8. We call the token demo-prometheus again and click on Create.

  9. In the next window we make sure to copy the token into the clipboard.

Configure a Prometheus instance

To configure a Prometheus server to send metrics into the demo instance, you need to add a remote_write block to its configuration. This is how a minimal configuration could look like:

global:
  scrape_interval:     5s
  evaluation_interval: 5s
  external_labels:
    cluster: demo

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
    - targets: ['localhost:9090']

remote_write:
- url: http://metrics-enterprise/api/prom/push
  basic_auth:
    username: demo
    password: <token>  # TODO: Set this to the token from your clipboard

Run this Prometheus configuration using Docker

To run this configuration make sure that the above configuration is stored locally in the file prometheus.yaml and then run those steps:

$ docker run \
   -d \
   --name=demo-prometheus \
   --network=metrics-enterprise \
   -v $(pwd)/prometheus.yaml:/etc/prometheus/prometheus.yml:z \
   prom/prometheus:v2.21.0

Querying metrics back through Grafana

Using the Grafana Explore, you should be able to query the data from your Prometheus through Metrics Enterprise