Using Grafana Provisioning
1. Understanding Provisioning Structure
| Provisioning Type | Configuration File | Description |
|---|---|---|
| Dashboard | dashboards.yaml |
Manages dashboard provisioning from files, URLs, or Git repositories. |
| DataSource | datasources.yaml |
Defines data sources for Grafana to connect to various backends like Prometheus, InfluxDB, etc. |
| Notification Channel | alerts.yaml |
Configures alert notification channels (e.g., email, Slack, PagerDuty). |
| Plugin | plugins.yaml |
Handles plugin installation and configuration. |
| Folder | folders.yaml |
Manages folder structure for organizing dashboards. |
Example: Dashboard Provisioning Configuration
apiVersion: 1
providers:
- name: "default"
orgId: 1
folder: ""
type: file
disableProvisioning: false
options:
path: /var/lib/grafana/dashboards
Example: Data Source Provisioning Configuration
apiVersion: 1
datasources:
- name: "Prometheus"
type: prometheus
access: proxy
url: http://localhost:9090
isDefault: true
Note: Provisioning files must be placed in the
/etc/grafana/provisioning directory or specified via the provisioning configuration in grafana.ini.
2. Provisioning Data Sources
| Property | Value | Description |
|---|---|---|
| name | string |
Name of the data source |
| type | string |
Type of the data source (e.g., prometheus, loki) |
| access | string |
Access mode (proxy or direct) |
| url | string |
URL of the data source endpoint |
| database | string |
Database name (for SQL-based sources) |
| jsonData | object |
Additional JSON configuration (e.g., tlsSkipVerify) |
| secureJsonData | object |
Secure JSON data (e.g., basicAuthPassword) |
| version | number |
Version of the data source (default: 1) |
| isDefault | boolean |
Set as default data source for the instance |
Example: Provisioning a Prometheus Data Source
datasources:
- name: "Prometheus"
type: "prometheus"
access: "proxy"
url: "http://localhost:9090"
isDefault: true
Example: Provisioning a Loki Data Source
datasources:
- name: "Loki"
type: "loki"
access: "proxy"
url: "http://localhost:3100"
jsonData:
logLabel: "__line__"
3. Provisioning Dashboards
| Property | Description | Example |
|---|---|---|
| dashboard | Dashboard configuration | |
| folder | Folder to place the dashboard in | "folder": "Production" |
| overwrite | Overwrite existing dashboard | "overwrite": true |
Example: Provisioning a Dashboard
apiVersion: 1
providers:
- name: 'my-provider'
orgId: 1
folder: 'Production'
type: file
disableProvisioning: false
options:
path: /var/lib/grafana/dashboards
Note: Ensure the dashboard JSON files are correctly formatted and placed in the specified directory.
4. Provisioning Alert Rules
| Property | Description | Example |
|---|---|---|
| name | Name of the alert rule | High CPU Usage |
| condition | Condition to evaluate (e.g., A > 80) |
A > 80 |
| for | Duration to wait before firing the alert | 5m |
| labels | Additional labels to attach to the alert | { severity: "critical" } |
| annotations | Annotations to provide additional context | { summary: "CPU usage is above 80%" } |
Example: Alert Rule Configuration
name: High CPU Usage
condition: A > 80
for: 5m
labels:
severity: critical
annotations:
summary: "CPU usage is above 80%"
Note: Alert rules must be defined within a folder structure under
/etc/grafana/provisioning/alerts.
5. Provisioning Contact Points
| Property | Description | Example |
|---|---|---|
| name | Name of the contact point | email-alerts |
| email_configs | Array of email configuration objects | |
Example: Email Contact Point Configuration
name: email-alerts
email_configs:
- to: team@example.com
from: alert@company.com
subject: "[{{.Status}}] Alert Triggered"
Note: Contact points can be configured to send alerts via email, Slack, PagerDuty, and more.
6. Provisioning Notification Policies
| Property | Description | Values | Notes |
|---|---|---|---|
| name | Name of the notification policy | string |
Required field |
| receiver | Name of the receiver to route alerts to | string |
Required field |
| group_by | Labels to group alerts by | []string |
Optional, defaults to ["alertname"] |
| group_wait | Time to wait before sending the first alert group | duration |
Optional, defaults to 30s |
| group_interval | Time to wait between sending alert groups | duration |
Optional, defaults to 5m |
| repeat_interval | Time to wait before resending an alert | duration |
Optional, defaults to 4h |
| matchers | Label matchers to filter alerts | []matcher |
Optional, defaults to no filtering |
Example: Basic Notification Policy
name: "Production Alerts"
receiver: "email-receiver"
group_by: ["alertname", "severity"]
group_wait: 30s
group_interval: 5m
repeat_interval: 4h
Example: Notification Policy with Matchers
name: "Database Alerts"
receiver: "slack-receiver"
matchers:
- name: "job"
value: "database"
is_regex: false
group_by: ["alertname"]
group_wait: 1m
group_interval: 3m
repeat_interval: 1h
7. Using Environment Variables (${VAR} syntax)
| Variable | Usage | Description |
|---|---|---|
| GF_DATABASE_URL | ${GF_DATABASE_URL} |
Database connection URL for Grafana |
| GF_SECURITY_ADMIN_PASSWORD | ${GF_SECURITY_ADMIN_PASSWORD} |
Admin password for Grafana |
| GF_SERVER_ROOT_URL | ${GF_SERVER_ROOT_URL} |
Root URL for Grafana server |
Example: Environment Variable in Config
datasources:
- name: "Prometheus"
type: prometheus
url: ${PROMETHEUS_URL}
access: proxy
Note: Environment variables are evaluated at startup. Changes require a Grafana restart to take effect.
8. Setting Provisioning Paths
| Path Type | Default Location | Description |
|---|---|---|
| provisioning | /etc/grafana/provisioning |
Directory for provisioning configuration files |
| provisioning.datasources | /etc/grafana/provisioning/datasources |
Directory for datasource provisioning files |
| provisioning.dashboard | /etc/grafana/provisioning/dashboards |
Directory for dashboard provisioning files |
| provisioning.notifiers | /etc/grafana/provisioning/notifiers |
Directory for alert notification provisioning files |
Example: Provisioning Directory Structure
/etc/grafana/provisioning/
├── datasources/
│ └── datasource.yml
├── dashboards/
│ └── dashboard.yml
└── notifiers/
└── notifier.yml
Note: The provisioning directory can be overridden using the
provisioning configuration option in grafana.ini.
9. Enabling Auto-Update
| Configuration Option | Description | Default Value | Notes |
|---|---|---|---|
| auto_update.enabled | Enables or disables the auto-update feature for Grafana | false |
Set to true to enable automatic updates |
| auto_update.check_interval | Interval (in seconds) between update checks | 3600 |
Defaults to 1 hour; set to lower values for more frequent checks |
| auto_update.update_channel | Update channel to use for checking updates | stable |
Options: stable, beta, nightly |
Example: Enabling Auto-Update in grafana.ini
[auto_update]
enabled = true
check_interval = 1800
update_channel = stable
Note: Auto-update requires Grafana to be able to access the internet and has no effect if Grafana is running in an offline environment.
10. Provisioning Plugins
| Plugin | Description | Provisioning Config | Status |
|---|---|---|---|
| grafana-piechart-panel | Visualize data as pie charts | |
NEW |
| grafana-worldmap-panel | Display data on a world map | |
Stable |
| grafana-clock-panel | Display a live clock | |
DEPRECATED |