devops4 min read

Grafana Tutorial: Learn Dashboards from Scratch (2026)

Grafana Tutorial: Learn Dashboards from Scratch (2026)

Published:  |  Category: Devops  |  Reading time: ~15 min
Grafana Tutorial: Learn Dashboards from Scratch (2026)

Before Grafana, I was building dashboards in Excel spreadsheets that I manually updated. Grafana changed observability by making real-time, interactive dashboards accessible to anyone. It connects to dozens of data sources — Prometheus, Loki, Elasticsearch, InfluxDB, CloudWatch — and visualizes data with panels, alerts, and annotations.

By the end of this tutorial, you will be able to design dashboards that communicate system health at a glance, use template variables to create interactive filters, and configure alerting rules that notify your team through Slack, email, or PagerDuty.

Installing Grafana and Connecting Data Sources

Grafana runs as a single binary, Docker container, or Helm chart on Kubernetes. The default port is 3000, and the initial admin credentials are admin/admin — change them immediately. Once logged in, the first step is adding data sources. Grafana supports Prometheus, Loki, Elasticsearch, InfluxDB, MySQL, PostgreSQL, and dozens more through plugins. I configure the Prometheus data source with the URL of the Prometheus server and set the scrape interval matching the Prometheus configuration.

docker run -d --name grafana -p 3000:3000 \
  -v grafana-data:/var/lib/grafana \
  -v grafana-config:/etc/grafana \
  grafana/grafana:latest

Building Dashboards with Panels and Rows

A Grafana dashboard consists of rows that organize panels. Each panel visualizes a query from a data source. Panel types include time series (line charts), bar charts, stat (single number), gauge, table, heatmap, and logs. I use time series panels for metric trends, stat panels for SLO compliance percentages. Thresholds color-code panel backgrounds based on value ranges. Panel repeats create dynamic dashboards: repeating a panel per instance or metric.

{
  "type": "timeseries",
  "title": "Request Rate",
  "thresholds": [
    { "value": 100, "color": "yellow" },
    { "value": 200, "color": "red" }
  ]
}

Template Variables for Dynamic Dashboards

Template variables turn static dashboards into interactive tools. A variable like $job or $instance becomes a dropdown selector that filters all panel queries. Variable types include Query (populated from a data source query), Custom (manually defined list), and Interval. The query variable type runs a PromQL query like label_values(up, job) to dynamically populate the list of available jobs.

{
  "name": "job",
  "type": "query",
  "query": "label_values(up, job)",
  "includeAll": true,
  "multi": true
}

Alerting in Grafana

Grafana Alerting supports Prometheus-style rule evaluation, multiple alert instances per rule, and flexible notification routing. Alert rules query data sources with thresholds and evaluation intervals. Notification policies route alerts to contact points (Slack, email, PagerDuty, webhook) using label matchers. Silences mute alerts for a specified time window during maintenance.

groups:
  - name: service_alerts
    rules:
      - alert: HighErrorRate
        expr: |
          sum(rate(http_requests_total{status=~"5.."}[5m]))
          /
          sum(rate(http_requests_total[5m])) > 0.05
        for: 5m

Dashboard Provisioning and As-Code Management

Manually creating dashboards through the UI does not scale. Grafana supports provisioning dashboards from JSON files stored in the filesystem. Each dashboard JSON is the same model that the UI produces — you can export it and commit to Git. I store dashboards in a Git repository and use a CI pipeline to sync them to Grafana instances.

# /etc/grafana/provisioning/datasources/prometheus.yaml
apiVersion: 1
datasources:
  - name: Prometheus
    type: prometheus
    access: proxy
    url: http://prometheus:9090
    isDefault: true

Advanced: Loki, Tempo, and Grafana Cloud

The Grafana ecosystem extends beyond metrics with Loki (log aggregation) and Tempo (distributed tracing). Loki indexes log metadata rather than content, making it cost-effective for high-volume logs. LogQL queries filter and aggregate log data, and you can jump from a metrics spike to correlating logs with a single click. Grafana Cloud is the managed SaaS offering.

# LogQL query in Loki
{job="nginx"} |= "ERROR" | json
# TraceQL query in Tempo
{ resource.service.name = "frontend" && span.http.status_code >= 500 } | duration > 1s

Frequently Asked Questions

Can I use Grafana with non-Prometheus data sources?

Yes. Grafana supports over 100 data sources including InfluxDB, Elasticsearch, CloudWatch, Azure Monitor, Google Cloud Monitoring, MySQL, PostgreSQL, and Graphite.

How do I share a Grafana dashboard?

You can share dashboards by generating a direct link, exporting the JSON model, or creating a snapshot. For public dashboards, Grafana supports anonymous access with viewer permissions.

What is the difference between Grafana Alerting and Prometheus Alertmanager?

Grafana Alerting is a unified alerting engine that works with any data source. Prometheus Alertmanager only handles alerts from Prometheus.

How do I handle Grafana high availability?

Grafana supports HA by running multiple instances behind a load balancer with a shared database (PostgreSQL) and session storage (Redis).

Originally published on Ayodhyyya. Last updated June 1, 2026.