Grafana Dashboards: Building and Sharing Visualizations
In this tutorial, you'll learn about Grafana Dashboards: Building and Sharing Visualizations. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.
What You Will Learn
This tutorial teaches you how to create Grafana dashboards from scratch, configure Prometheus as a data source, design panels with PromQL queries, and share dashboards with your team.
Why It Matters
Raw metrics are hard to read. Grafana turns them into visual stories that help you spot trends, debug incidents, and communicate system health to stakeholders in seconds.
Real-World Use
The DodaTech operations team uses a single Grafana dashboard to monitor all production services. When an engineer joins the on-call rotation, the first thing they do is open the master dashboard to see service health at a glance.
Grafana is the leading open-source analytics and visualization platform. It connects to dozens of data sources including Prometheus, Loki, Graphite, and InfluxDB. Dashboards are composed of panels that display time-series data as graphs, tables, gauges, and heatmaps.
Prerequisites
- A running Prometheus instance (see Prometheus Introduction)
- A machine with Docker or direct access to install Grafana
- Port 3000 accessible in your firewall
- Basic understanding of PromQL queries
Step-by-Step Tutorial
Step 1: Install Grafana
# Using Docker
docker run -d --name grafana -p 3000:3000 grafana/grafana:11.1.0
# Using APT on Ubuntu
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
sudo apt-get update
sudo apt-get install grafana
sudo systemctl start <a href="/devops/prometheus-grafana/">Grafana</a>-server
Expected output: Grafana starts and listens on port 3000.
Step 2: Log In and Add a Data Source
Navigate to http://localhost:3000. The default credentials are admin/admin. Grafana will prompt you to change the password on first login.
- Click the gear icon (Configuration) on the left sidebar
- Select Data Sources
- Click Add data source
- Choose Prometheus
- Set the URL to
http://host.docker.internal:9090(Docker) orhttp://localhost:9090(binary) - Click Save & Test
Expected output: A green banner says "Data source is working."
Step 3: Create Your First Dashboard
- Click the plus icon on the sidebar and select Dashboard
- Click Add visualization
- Select your Prometheus data source
- Enter this query in the PromQL field:
rate(prometheus_http_requests_total[5m])
- In the panel options on the right, set:
- Title: HTTP Request Rate
- Unit: cps (counts per second)
- Type: Time series
Step 4: Add Multiple Panels
Click Add > New panel at the top. Add a second panel with this query:
node_memory_MemAvailable_bytes
Set the unit to bytes (SI) and title to Available Memory.
Step 5: Create a Stat Panel for Quick Health
Add a third panel and change the visualization type to Stat:
avg(node_load1)
Stat panels show a single value that updates in real time -- perfect for at-a-glance health indicators.
Step 6: Use Template Variables
Template variables make dashboards reusable across environments.
- Click the gear icon (Dashboard Settings)
- Go to Variables > Add variable
- Name:
instance - Type: Query
- Data source: Prometheus
- Query:
label_values(node_load1, instance) - Click Update
Now use $instance in your panel queries:
node_memory_MemAvailable_bytes{instance="$instance"}
This lets you switch between servers with a dropdown.
Step 7: Set Up Dashboard Annotations
Annotations mark events on time-series graphs.
- Go to Dashboard Settings > Annotations > Add annotation
- Name: Deploy Events
- Data source: Prometheus
- Query:
deploy_timestamp > 0
Now every deploy event shows as a vertical line across all panels.
Step 8: Share the Dashboard
- Click the Share icon at the top of the dashboard
- Choose the Link tab to copy a direct URL
- Choose the Export tab to download a JSON model
- Choose the Embed tab to get an iframe snippet for embedding
For team sharing, save the dashboard JSON in your Git repository and use Grafana's provisioning feature.
Learning Path
flowchart LR
A[Install Grafana] --> B[Add Data Source]
B --> C[Create Panels]
C --> D[Add Variables]
D --> E[Set Annotations]
E --> F[Share Dashboard]
C -.-> G[Time Series]
C -.-> H[Stat]
C -.-> I[Table]
style A fill:#4a90d9,color:#fff
style F fill:#e67e22,color:#fff
Common Errors
Data source says HTTP error 400 -- The URL is wrong or Grafana cannot reach Prometheus. If using Docker, use
host.docker.internalinstead oflocalhost.Panel shows "No data" -- The PromQL query returns no results. Verify the metric exists in Prometheus and check label filters.
Template variable dropdown is empty -- The query in the variable definition returned no labels. Ensure the metric exists and has the expected label name.
Dashboard loads slowly -- Too many panels querying wide time ranges. Reduce the time range, use recording rules, or add panel-level caching.
Embedded dashboard does not render -- Anonymous access must be enabled in
<a href="/devops/prometheus-grafana/">Grafana</a>.iniunder[auth.anonymous].Annotation lines do not appear -- The annotation query must return a numeric value at the event timestamp. Verify the metric is present.
Changes are lost after page refresh -- You must save the dashboard (Ctrl+S or the Save icon) before refreshing.
Practice Questions
What is the default port for Grafana? Answer: 3000.
How do you make a dashboard reusable across different environments? Answer: Use template variables that allow selecting server instance, environment, or region from a dropdown.
What is the difference between a Time Series panel and a Stat panel? Answer: Time Series shows data over time as a line graph; Stat shows a single aggregated value.
How can you share a dashboard without giving access to the Grafana server? Answer: Export the dashboard as JSON and import it into another Grafana instance, or use provisioning files.
What is the purpose of an annotation in Grafana? Answer: To mark events (deploys, config changes, incidents) as vertical lines on graphs for correlation.
Challenge
Build a full-screen NOC dashboard with four rows: the first row shows four Stat panels for overall system health (CPU, memory, disk, load), the second row shows a time-series graph of HTTP traffic broken down by status code, the third row shows a table of the top 10 instances by error rate, and the fourth row shows a heatmap of request latency. Use template variables for instance selection and add deploy annotations. Export the final JSON and verify it imports cleanly into a fresh Grafana instance.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro