Grafana OSS
Docs: https://grafana.com/docs/grafana/latest.md
Common Workflows
Provisioning dashboards from disk
- Drop dashboard JSON file(s) under
/var/lib/grafana/dashboards/
- Add a provider in
provisioning/dashboards/default.yaml (see § Dashboard provisioning below)
- Restart Grafana so the provider config is loaded
- Verify the dashboard landed:
curl https://grafana.example.com/api/dashboards/uid/<uid> \
-H "Authorization: Bearer <token>" | jq '.dashboard.title'
Returns the title → success. 404 → provisioning didn't pick it up; check Grafana server logs (journalctl -u grafana-server | grep -i provisioning) for parse errors.
Provisioning data sources
- Write
provisioning/datasources/datasources.yaml (see § Data source provisioning below)
- Restart Grafana
- Health-check the data source via API:
curl https://grafana.example.com/api/datasources/uid/<uid>/health \
-H "Authorization: Bearer <token>"
# { "status": "OK", "message": "..." } → working
# { "status": "ERROR", ... } → URL unreachable or auth misconfigured
Creating a service account + token
- Provision via YAML or
POST /api/serviceaccounts (full API in references/api.md § Users + service accounts)
- Mint a token via
POST /api/serviceaccounts/{id}/tokens
- Verify the token works:
curl https://grafana.example.com/api/org \
-H "Authorization: Bearer <new-token>"
# 200 + org JSON → token + role assignment work
# 401 → token wrong; 403 → role wrong
Dashboard provisioning
# provisioning/dashboards/default.yaml
apiVersion: 1
providers:
- name: default
folder: MyFolder
type: file
disableDeletion: false
updateIntervalSeconds: 30
options:
path: /var/lib/grafana/dashboards
foldersFromFilesStructure: true
For the dashboard JSON shape itself (panels, queries, template variables), see references/dashboard-json.md.
Data source provisioning
# provisioning/datasources/datasources.yaml
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
jsonData:
timeInterval: 15s
httpMethod: POST
- name: Loki
type: loki
access: proxy
url: http://loki:3100
- name: Tempo
type: tempo
access: proxy
url: http://tempo:3200
jsonData:
tracesToLogsV2:
datasourceUid: loki_uid
tags: [{ key: "service.name", value: "app" }]
serviceMap:
datasourceUid: prometheus_uid
nodeGraph:
enabled: true
- name: Pyroscope
type: grafana-pyroscope-datasource
url: http://pyroscope:4040
RBAC (built-in roles)
| Role |
Permissions |
| Viewer |
Read dashboards, alerts |
| Editor |
Create/edit dashboards, alerts |
| Admin |
Manage data sources, users, plugins |
| GrafanaAdmin |
Server-wide admin (superuser) |
Service-account provisioning:
# provisioning/access-control/service_accounts.yaml
apiVersion: 1
serviceAccounts:
- name: ci-reader
orgId: 1
role: Viewer
tokens:
- name: ci-token
# expires: optional ISO 8601 timestamp; omit for no-expiry tokens
(Custom RBAC roles with fine-grained permissions are Enterprise / Cloud only — see the grafana-cloud/admin skill if you need those.)
Plugin provisioning
# provisioning/plugins/plugins.yaml
apiVersion: 1
apps:
- type: grafana-pyroscope-app
disabled: false
jsonData:
backendUrl: http://pyroscope:4040
After restart, verify via GET /api/plugins/<plugin-id>/health.
References
references/dashboard-json.md — full dashboard JSON model + template variables + common problems (uid uniqueness, gridPos arithmetic, datasource uid matching)
references/dashboards.md — dashboard workflows, settings, variables, annotations, sharing, versions, playlists, and provisioning-as-code
references/datasources.md — data source setup and query examples for Prometheus, Loki, Tempo, SQL, CloudWatch, and plugins
references/panel-types.md — panel-type table + decision guide for picking the right one
references/panels.md — panel editor, visualization options, field config, transformations, query options, inspection, and performance tips
references/alerting.md — alerting concepts, contact points, notification policies, templates, silences, and common rule examples
references/api.md — full Grafana OSS API reference (dashboards, data sources, users, service accounts, annotations) with verification curls and common failure modes
references/config.md — grafana.ini server / database / SMTP / auth / security / feature-toggle config + restart-required issues
1---2name: grafana-oss3description: Configure Grafana OSS — provisions dashboards from YAML, sets up data sources (Prometheus / Loki / Tempo / Pyroscope), writes dashboard JSON with template variables, builds panel queries, assigns built-in roles (Viewer / Editor / Admin / GrafanaAdmin), mints service-account tokens, edits grafana.ini server config, creates annotations, installs plugins via provisioning, and validates each step with a health-check curl. Use when building dashboards, configuring data sources, setting up provisioning YAML, picking a panel type, writing template variables, managing users and roles, configuring SMTP/OAuth in grafana.ini, creating annotations via API, troubleshooting why a provisioned dashboard isn't showing up, or running Grafana OSS locally — even when the user says "set up a Prometheus data source", "provision dashboards from git", "make a service account", or "configure SSO in OSS" without saying "Grafana OSS".4license: Apache-2.05---6
7# Grafana OSS
8
9> **Docs**: https://grafana.com/docs/grafana/latest.md
10
11## Common Workflows
12
13### Provisioning dashboards from disk
14
151. Drop dashboard JSON file(s) under `/var/lib/grafana/dashboards/`
162. Add a provider in `provisioning/dashboards/default.yaml` (see [§ Dashboard provisioning](#dashboard-provisioning) below)
173. Restart Grafana so the provider config is loaded
184. **Verify the dashboard landed**:
19 ```bash
20 curl https://grafana.example.com/api/dashboards/uid/<uid> \
21 -H "Authorization: Bearer <token>" | jq '.dashboard.title'
22 ```
23 Returns the title → success. 404 → provisioning didn't pick it up; check Grafana server logs (`journalctl -u grafana-server | grep -i provisioning`) for parse errors.
24
25### Provisioning data sources
26
271. Write `provisioning/datasources/datasources.yaml` (see [§ Data source provisioning](#data-source-provisioning) below)
282. Restart Grafana
293. **Health-check the data source via API**:
30 ```bash
31 curl https://grafana.example.com/api/datasources/uid/<uid>/health \
32 -H "Authorization: Bearer <token>"
33 # { "status": "OK", "message": "..." } → working
34 # { "status": "ERROR", ... } → URL unreachable or auth misconfigured
35 ```
36
37### Creating a service account + token
38
391. Provision via YAML or `POST /api/serviceaccounts` (full API in [references/api.md § Users + service accounts](references/api.md#users--service-accounts))
402. Mint a token via `POST /api/serviceaccounts/{id}/tokens`
413. **Verify the token works**:
42 ```bash
43 curl https://grafana.example.com/api/org \
44 -H "Authorization: Bearer <new-token>"
45 # 200 + org JSON → token + role assignment work
46 # 401 → token wrong; 403 → role wrong
47 ```
48
49## Dashboard provisioning
50
51```yaml
52# provisioning/dashboards/default.yaml
53apiVersion: 1
54providers:
55 - name: default
56 folder: MyFolder
57 type: file
58 disableDeletion: false
59 updateIntervalSeconds: 30
60 options:
61 path: /var/lib/grafana/dashboards
62 foldersFromFilesStructure: true
63```
64
65For the dashboard JSON shape itself (panels, queries, template variables), see [references/dashboard-json.md](references/dashboard-json.md).
66
67## Data source provisioning
68
69```yaml
70# provisioning/datasources/datasources.yaml
71apiVersion: 1
72datasources:
73 - name: Prometheus
74 type: prometheus
75 access: proxy
76 url: http://prometheus:9090
77 isDefault: true
78 jsonData:
79 timeInterval: 15s
80 httpMethod: POST
81
82 - name: Loki
83 type: loki
84 access: proxy
85 url: http://loki:3100
86
87 - name: Tempo
88 type: tempo
89 access: proxy
90 url: http://tempo:3200
91 jsonData:
92 tracesToLogsV2:
93 datasourceUid: loki_uid
94 tags: [{ key: "service.name", value: "app" }]
95 serviceMap:
96 datasourceUid: prometheus_uid
97 nodeGraph:
98 enabled: true
99
100 - name: Pyroscope
101 type: grafana-pyroscope-datasource
102 url: http://pyroscope:4040
103```
104
105## RBAC (built-in roles)
106
107| Role | Permissions |
108|------|-------------|
109| **Viewer** | Read dashboards, alerts |
110| **Editor** | Create/edit dashboards, alerts |
111| **Admin** | Manage data sources, users, plugins |
112| **GrafanaAdmin** | Server-wide admin (superuser) |
113
114Service-account provisioning:
115
116```yaml
117# provisioning/access-control/service_accounts.yaml
118apiVersion: 1
119serviceAccounts:
120 - name: ci-reader
121 orgId: 1
122 role: Viewer
123 tokens:
124 - name: ci-token
125 # expires: optional ISO 8601 timestamp; omit for no-expiry tokens
126```
127
128(Custom RBAC roles with fine-grained permissions are Enterprise / Cloud only — see the `grafana-cloud/admin` skill if you need those.)
129
130## Plugin provisioning
131
132```yaml
133# provisioning/plugins/plugins.yaml
134apiVersion: 1
135apps:
136 - type: grafana-pyroscope-app
137 disabled: false
138 jsonData:
139 backendUrl: http://pyroscope:4040
140```
141
142After restart, verify via `GET /api/plugins/<plugin-id>/health`.
143
144## References
145
146- [`references/dashboard-json.md`](references/dashboard-json.md) — full dashboard JSON model + template variables + common problems (uid uniqueness, gridPos arithmetic, datasource uid matching)
147- [`references/dashboards.md`](references/dashboards.md) — dashboard workflows, settings, variables, annotations, sharing, versions, playlists, and provisioning-as-code
148- [`references/datasources.md`](references/datasources.md) — data source setup and query examples for Prometheus, Loki, Tempo, SQL, CloudWatch, and plugins
149- [`references/panel-types.md`](references/panel-types.md) — panel-type table + decision guide for picking the right one
150- [`references/panels.md`](references/panels.md) — panel editor, visualization options, field config, transformations, query options, inspection, and performance tips
151- [`references/alerting.md`](references/alerting.md) — alerting concepts, contact points, notification policies, templates, silences, and common rule examples
152- [`references/api.md`](references/api.md) — full Grafana OSS API reference (dashboards, data sources, users, service accounts, annotations) with verification curls and common failure modes
153- [`references/config.md`](references/config.md) — `grafana.ini` server / database / SMTP / auth / security / feature-toggle config + restart-required issues