Dashboard Import/Export
Introduction
One of the most powerful features of Grafana is the ability to share and reuse dashboards across different Grafana instances. The Dashboard Import/Export functionality allows you to save your carefully crafted dashboards as JSON files, share them with the community, or move them between different Grafana environments. This is particularly useful for:
- Backing up your dashboards
- Sharing dashboards with teammates
- Moving dashboards between development, staging, and production environments
- Contributing to or benefiting from the Grafana community dashboard library
In this guide, we'll explore how to export your existing dashboards and import dashboards from various sources.
Exporting Dashboards
Basic Dashboard Export
Exporting a dashboard in Grafana is straightforward:
- Navigate to the dashboard you want to export
- Click on the "Share" icon in the top navigation bar
- Select the "Export" tab
- Click "Save to file"
This will download a JSON file containing all the dashboard configurations, panels, and queries.
Here's what the export button looks like in the Grafana interface:
Examining the Exported JSON
Let's take a look at a simplified example of what an exported dashboard JSON file might contain:
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": 1,
"links": [],
"panels": [
{
"datasource": "Prometheus",
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 2,
"options": {},
"targets": [
{
"expr": "up",
"refId": "A"
}
],
"title": "System Uptime",
"type": "stat"
}
],
"refresh": "5s",
"schemaVersion": 22,
"style": "dark",
"tags": ["monitoring", "example"],
"templating": {
"list": []
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Example Dashboard",
"uid": "abcdefghi",
"version": 1
}
Key components in the exported JSON:
- annotations: Marks specific points on your graphs
- panels: The individual visualizations in your dashboard
- templating: Variables used to make the dashboard dynamic
- time: Default time range for the dashboard
- title: Dashboard name
- uid: Unique identifier for the dashboard
Export for Sharing
When exporting for sharing with others, you can choose to:
- Click "Export for sharing externally" instead of "Save to file"
- This option will remove sensitive data like datasource specific configurations
Importing Dashboards
Grafana offers multiple ways to import dashboards.
Import from File
To import a dashboard from a JSON file:
- Navigate to Dashboards > Import in the side menu
- Click "Upload JSON file"
- Select your dashboard JSON file
- Review the dashboard settings
- Click "Import"
Import from grafana.com
Grafana has a community dashboard repository at grafana.com/dashboards with thousands of pre-built dashboards:
- Browse to a dashboard you want on grafana.com
- Copy the dashboard ID (a numeric value)
- In your Grafana instance, go to Dashboards > Import
- Paste the ID in the "Import via grafana.com" field
- Click "Load"
- Configure any required datasources
- Click "Import"
Here's a visualization of the import process:
Import via JSON Text
You can also paste a dashboard JSON directly:
- Go to Dashboards > Import
- Select the "Import via panel json" tab
- Paste your JSON content
- Click "Load"
- Configure settings and datasources
- Click "Import"
CLI Import/Export
For automated workflows, you can use the Grafana API with tools like curl
:
Export a dashboard:
curl -H "Authorization: Bearer YOUR_API_KEY" \
http://your-grafana-instance/api/dashboards/uid/YOUR_DASHBOARD_UID \
> dashboard.json
Import a dashboard:
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d @dashboard.json \
http://your-grafana-instance/api/dashboards/db
Handling Dashboard Variables and Data Sources
When importing dashboards, you'll often need to map data sources from the original dashboard to your own Grafana instance:
- During import, Grafana will detect data source references
- You'll be prompted to select which of your data sources to use
- Select the appropriate data source for each required field
For example, if the original dashboard used a Prometheus data source named "Production Metrics", you'll need to select your equivalent Prometheus data source.
Versioning and Dashboard History
Grafana keeps a history of dashboard changes:
- Go to the dashboard settings (gear icon)
- Select "Versions" tab
- Here you can see previous versions, compare them, and restore if needed
This is a valuable feature when working with imported dashboards that you might need to customize.
Real-World Example: Monitoring System Performance
Let's walk through a common workflow:
- You need to monitor your system's performance
- Search for "Node Exporter" on grafana.com
- Find the popular "Node Exporter Full" dashboard (ID: 1860)
- Import it using the dashboard ID
- Map your Prometheus data source
- Customize as needed for your environment
This saves you hours of creating complex dashboards from scratch.
Practical Tips
Sharing with Variables
When sharing dashboards that use template variables:
- Consider setting default values for variables
- Document any required data source queries
- Include a README panel explaining how to use the dashboard
Dashboard Provisioning
For DevOps workflows, you can automate dashboard deployment using Grafana's provisioning feature:
- Place your dashboard JSON files in the provisioning directory
- Configure the
provisioning/dashboards/
path in Grafana - Restart Grafana or trigger a provisioning reload
Example provisioning config (dashboard.yaml
):
apiVersion: 1
providers:
- name: 'default'
orgId: 1
folder: 'Production'
type: file
disableDeletion: false
updateIntervalSeconds: 10
options:
path: /var/lib/grafana/dashboards
Exporting for Different Grafana Versions
When exporting dashboards to be used in different Grafana versions:
- Be aware that newer features might not work in older versions
- Test the dashboard in the target Grafana version
- Consider maintaining separate versions for major Grafana releases
Summary
Dashboard import/export is a fundamental skill for any Grafana user. It allows you to:
- Save time by reusing existing dashboards
- Share your work with the community
- Implement consistent monitoring across different environments
- Back up your visualization configurations
By mastering these techniques, you'll be able to leverage the collective knowledge of the Grafana community and efficiently manage your dashboards across different instances.
Further Learning
To deepen your understanding of Grafana dashboard management:
- Experiment with importing dashboards from the Grafana community
- Try exporting and modifying existing dashboards
- Learn about dashboard provisioning for automated deployment
- Explore the Dashboard JSON model to understand how dashboards are structured
Exercises
- Export one of your existing dashboards and examine the JSON structure
- Import a dashboard from grafana.com related to a technology you use
- Modify an imported dashboard to match your specific monitoring needs
- Create a simple script to automate dashboard backup using the Grafana API
- Set up dashboard provisioning in a test environment
If you spot any mistakes on this website, please let me know at [email protected]. I’d greatly appreciate your feedback! :)