Grafana rarely gets hacked — more often it simply "temporarily" gets admin for everyone. Six months later nobody retracts the rights, and the dashboards already show what only half the company should see. Three layers of protection, dissected: roles, secrets and the data itself.
Roles: who sees what
- The basic roles are Admin, Editor, Viewer. For most teams these are enough: Viewer looks, Editor edits dashboards, Admin manages users and data sources. Fine-graining goes through permissions on folders and dashboards, inherited from the folder down.
- Login via SSO. OIDC or SAML integration with the corporate IdP; IdP groups map onto Grafana roles. Local accounts exist only for service scenarios and break-glass access.
- Service accounts instead of admin:admin. Integrations (an IaC provider, dashboard export to git) get a service account with minimal rights and a rotating token.
- Least privilege. A developer doesn't need to modify data sources; an analyst doesn't need to add panels to the prod folder. Rights are granted per folder, not globally; temporary roles expire with the release or the audit.
Secrets: not in dashboards and not in git
- Grafana encrypts data source passwords in its own DB with the
SECRET_KEYfromgrafana.ini; the key itself lives in a secret manager, not in the repository. Losing the key means re-entering every source's password. - The OAuth
client_secretand Vault tokens travel via environment variables or provisioning, with values injected from Vault / AWS Secrets Manager / External Secrets Operator. - Dashboards must contain no secrets: no API keys in panel queries, no tokens in annotations — the dashboard JSON goes to git, and that is a public artifact.
- Scheduled rotation: service tokens — 90 days, OAuth secrets — per IdP policy; access revocation is part of offboarding, not "someday".
Data privacy
- Access to data happens at the source level: datasource permissions decide who can even run a query against Prometheus, Loki or Tempo, not just "see a dashboard".
- PII in logs gets masked on the storage side (a pipeline in Loki/ES), not in Grafana: whoever exports logs through the API must receive already anonymized lines.
- CSV export from panels and public snapshots — restricted: this is the easiest way to "leak a table" with one click.
- Anonymous access (
org_role = Viewer) — deliberate, and only for the on-call wall dashboards; usage stats going outward — off.
Audit
The action log (who changed a dashboard, a role or a source) goes to the SIEM or the same Loki; alerts — on role changes and the appearance of new admins. Once a quarter — a review: whose rights remain from closed projects, whose service accounts nobody needs anymore.
The rule is simple: access to Grafana must be designed like access to the data visible through it. A dashboard is a window; a data source is a door.
These are notes based on the lesson "Security and access: RBAC, secrets and data privacy" from the "Grafana for observability and monitoring" course at datafinder.ru.
Provisioning as code: access without "console clicks"
Rights, sources and folders configured with a mouse live in the head of whoever configured them. Provisioning turns RBAC into git artifacts: an access change is a merge request, not "drop by and tick a box".
# provisioning/datasources/prometheus.yml
apiVersion: 1
datasources:
- name: prom-prod
type: prometheus
access: Proxy
url: http://prometheus.internal:9090
isDefault: true
jsonData:
httpHeaderName1: "X-Scope-OrgID"
secureJsonData:
httpHeaderValue1: "${GRAFANA_DS_TOKEN}"
# provisioning/dashboards/folder-permissions.yml
apiVersion: 1
groups:
- orgId: 1
folder: Payments
editors: ["team-payments", "sre"]
viewers: ["support"]
On container rebuild Grafana applies the whole catalog: the state of the rights is always recoverable from the repository, and the review diff shows who granted what to whom.
Break-glass: access at 3 a.m.
- A separate local admin account with the password in a vault (or break-glass roles in the IdP): used when the IdP is unreachable and the dashboard is needed now.
- Its login is an audit event: any break-glass login automatically creates an incident for the morning review. Not "noticed in the logs a month later" but a review next morning.
- A separate account per emergency scenario, not a "shared admin": attribution of actions matters more than convenience.
The access review: what to check quarterly
| Check | Sign of a problem | What to do |
|---|---|---|
| Users with Admin | more than the actual platform team members | go over each one: why, who owns it |
| Service accounts | token older than 90 days, or the owner has left | rotate or delete |
| Folder permissions | teams with rights in someone else's prod folders | narrow down to their own |
| Local accounts | neither break-glass nor service ones | move to SSO or delete |
| Dashboards with external links | public snapshots older than a month | clean up; enable public access only deliberately |
The review takes an hour per quarter and saves weeks of "how did that contractor see our graphs".