Connect Grafana
Catalog Grafana's dashboards, charts and data sources with a pipeline that signs in with Marmot's identity, so there's no service account token to create, store or rotate. Grafana fetches your instance's public keys from your instance, and your instance connects to Grafana with a short-lived token. Tasks use the same sign-in for the Grafana tools.
Before you start
- You hold
ingestion.adminacross the whole catalog in your instance. - You can change Grafana's configuration (
grafana.inior itsGF_*environment variables) and restart it. - Grafana can reach your instance over https, to fetch its keys.
- Your instance can reach Grafana at a public address. For a Grafana on a private network, use a runner instead.
How it works
Before every run, connection test, query and tool call, your instance gives the pipeline a 5-minute token with the pipeline as its subject and Grafana's own address as the audience, so a token is only good for the Grafana it was sent to. Grafana checks it against your instance's published keys and signs the pipeline in as a Grafana user named after the subject; Workload identity explains the model.
Values you'll need
Replace <instance> and <grafana-host> with your own:
- Issuer:
https://<instance>.marmotdata.cloud. Always themarmotdata.cloudaddress, even with a custom domain - Key set URL:
https://<instance>.marmotdata.cloud/.well-known/jwks.json - Audience:
https://<grafana-host>, the scheme, host and port of the Grafana URL the pipeline uses, with no path - Subject:
pipeline:<pipeline-name>, the name you give the pipeline
The add source form shows all four, and the grafana.ini block with them filled in, as soon as you choose Marmot's identity and enter Grafana's URL.
Trust your instance in Grafana
Turn on JWT authentication in
grafana.ini:[auth.jwt]enabled = trueheader_name = Authorizationusername_claim = subauto_sign_up = truejwk_set_url = https://<instance>.marmotdata.cloud/.well-known/jwks.jsonexpect_claims = {"iss": "https://<instance>.marmotdata.cloud", "aud": ["https://<grafana-host>"], "sub": "pipeline:<pipeline-name>"}role_attribute_path = join('', ['Viewer'])role_attribute_strict = trueexpect_claimsadmits this pipeline only. Then restart Grafana. With the Helm chart or Docker, set the same keys asGF_AUTH_JWT_ENABLED,GF_AUTH_JWT_JWK_SET_URLand so on.role_attribute_path = join('', ['Viewer'])makes every pipeline a Viewer, which reads dashboards, library panels, the data source list and, for tools, queries. If your Grafana restricts data source permissions, grant each pipeline's user Query on the data sources it should reach. Don't shorten it to'Viewer':grafana.inistrips the outer quotes, so Grafana readsVieweras a claim name and refuses sign-in.Add the pipeline
- Open Plugins and select Grafana under Add a source.
- Choose Marmot's identity and enter Grafana's URL.
- Name the pipeline, then select Test connection. The test signs in to Grafana as the pipeline.
- Set a schedule and select Create pipeline.
Check that it worked
Open the pipeline under Plugins and select Run now. The run succeeds, your dashboards appear in Discover, and Grafana lists a user named pipeline:<pipeline-name> under Administration, Users.
Troubleshooting
| What you see | What to do |
|---|---|
401 Unauthorized from Grafana | Check that iss, aud and sub in expect_claims match the values the add source form shows, character for character |
Name the pipeline first: it signs in as Marmot under that name | Name the pipeline before testing the connection |
signing in with Marmot's identity needs the address the token is sent to | Enter Grafana's URL, starting with https:// |
| The run reads dashboards but no data sources | The Viewer can't list them on your Grafana. Grant the pipeline's user the permission |
Things to know
- Without
subinexpect_claims, any pipeline in your instance that signs in this way gets a Viewer user of its own. - Renaming the pipeline signs it in as a new Grafana user. Update
expect_claimsand grant data source permissions again, or keep the name. - Grafana caches the key set for
cache_ttl(60 minutes by default). Your instance publishes a new key a day before it signs with it, so the cache never misses one. - A Grafana service account token still works: choose Service account token instead.