A Grafana API key is the older way of giving a script or integration access to the Grafana HTTP API. Each key carries one organization role, Viewer, Editor or Admin, and whoever holds it acts with that role. An Editor or Admin key can change dashboards and alert rules and, depending on the setup, data source settings, which often include credentials for the databases and cloud accounts that Grafana reads from. Grafana has deprecated these keys in favour of service account tokens and migrates existing ones automatically, but a migrated key can keep working, so an old leaked key is still dangerous. Revoke it first, then look at what it changed.
Check your GitHub account for leaked secrets — free
- Provider
- Grafana
- Severity
- High
- Impact
- SaaS account access and billing
- Checked live by LeakWatch
- No
What a Grafana API Key looks like
A legacy Grafana API key is a long base64 string. It always begins with eyJrIjoi, which is the base64 encoding of the start of a small JSON object, followed by a body of letters and digits, usually ending in one or two = signs:
eyJrIjoiXXXXXXXX…XXXX== legacy Grafana API key (masked)
It is sent as a bearer token in the Authorization header of requests to a Grafana instance, and it often sits in variables named GRAFANA_API_KEY or GF_API_KEY, in dashboard-as-code tools, in Terraform provider settings and in CI scripts that deploy dashboards. The prefix is shared by any base64 JSON that starts the same way, so context matters. Do not mix it up with a JWT, which starts with eyJ but has three dot-separated parts, or with a service account token, which is the current replacement.
How Grafana API Keys get leaked
- Dashboard deployment scripts. A script that pushes dashboards through the HTTP API, with the key typed into the file.
- Terraform and provisioning code. Provider blocks with the key inline, committed to infrastructure repositories.
- Environment files and CI variables.
.envfiles committed by mistake, or pipeline logs that echo the environment. - Plugins and integrations. Example configuration for a data source or alert integration shared in an issue with the real key left in.
- Old repositories. Keys created years ago for a one-off job and never removed, now sitting in forgotten history.
What to do in the first hour
- Find the key in Grafana. Sign in to the Grafana instance the key belongs to as an administrator and open the area where API keys or service accounts are managed. Keys that were migrated now appear as service account tokens.
- Check the role. Note whether the key was Viewer, Editor or Admin. That sets how far to investigate.
- Create a replacement as a service account token with the lowest role that works, and set an expiry date if the option is offered.
- Deploy the replacement to the scripts and pipelines, then confirm they still work.
- Delete the exposed key (or its migrated token). Then call the API with the old value to confirm that it is rejected.
- Review changes. Look at dashboard and alert rule versions, the list of data sources, folders and users for anything you did not do. Grafana versions that offer audit logs record who changed what, so use them if available to you.
- Rotate data source credentials if the key was an Editor or Admin key and data source settings were readable or editable. Treat the passwords stored there as exposed.
- Clean up the code and search for related secrets. See I accidentally pushed an API key to GitHub.
Not sure what else leaked from the same repository? Run a free scan.
Revoke it at Grafana
Grafana API keys live inside a Grafana instance, so there is no single global page: you sign in to the instance, on Grafana Cloud or self-hosted, with a user who can administer it. Grafana’s documentation says legacy API keys are migrated to service accounts, and the migration guide lists where the keys and the resulting tokens are managed. Delete the exposed key or token from that list. A person has not confirmed the exact menu wording for this guide, and the interface changes between versions, so look for the section under users and access where service accounts and their tokens are listed, and follow Grafana’s documentation.
How LeakWatch detects it
The rule is called Grafana API Key. It looks for the prefix eyJrIjoi followed by 70 to 400 letters and digits, with optional = padding, as a whole word. The value must be followed by a quote, a backtick, whitespace, a semicolon, an escaped line break or the end of the text. A shorter body, or a base64 string with a different start, is not reported. The severity is high. This type is not checked live: LeakWatch does not send any request to Grafana with the key it found, and it cannot tell which instance the key belongs to.
LeakWatch detects this format but does not check it live: it can tell you the key is exposed, not whether it still works. Assume it does until you have revoked it.
FAQ
Grafana says API keys are deprecated. Can a leaked one still work?
Yes. Existing keys were migrated to service accounts rather than switched off, so a key from before the deprecation may still authenticate. Do not assume it is dead; delete it and check.
Does the key give access to my databases?
Not directly, but an Editor or Admin key may read or change data source settings, and those can contain database or cloud credentials. Rotate them if there is any doubt.
How do I find which instance a key belongs to?
The key does not name its instance. Look at the repository for the Grafana URL used with it, and check each instance you run, including old staging ones.