Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ElijahLynn/2375652b20b064343363bb6fde10f397 to your computer and use it in GitHub Desktop.
Save ElijahLynn/2375652b20b064343363bb6fde10f397 to your computer and use it in GitHub Desktop.
How to auth to Grafana Cloud Prometheus using an Access Policy Token with promtool

The docs are here but don't specify this level of detail, I found this through trial/error: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#http_config

Also see, prometheus/prometheus#12924.

  1. Set your access policy up and create a token for it at https://grafana.com/orgs/{{ORG_NAME}}/access-policies
  2. Get your QUERY_ENDPOINT + INSTANCE_ID from https://grafana.com/orgs/{{ORG_NAME}}/members, then click your stack on the left, https://grafana.com/orgs/hedera/stacks/{{STACK_ID}}, then click Prometheus and scroll down to get your Instance ID (https://grafana.com/orgs/hedera/hosted-metrics/{{USERNAME/INSTANCE_ID}}
  3. Then create a file with the creds, e.g. .promtool-http-config.yml with the below format:
    authorization:
      type: Bearer
      credentials: {{INSTANCE_ID}}:{{TOKEN}}
  4. Then run your query promtool query instant --http.config.file=.prom-http-config.yml {{QUERY_ENDPOINT}} {{QUERY}} e.g.
    promtool query instant --http.config.file=.promtool-http-config.yml prometheus-blocks-prod-us-central1.grafana.net/api/prom {{QUERY}}
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment