Visualising Metrics with Grafana Dashboards
Turn PromQL into panels, rows, and dashboards your whole team can read at a glance.
Prometheus stores the numbers; Grafana makes them make sense. In this lesson youβll connect Grafana to Prometheus, build panels from PromQL, and learn what separates a useful dashboard from a wall of noise.
π― Learning Objectives
- Add Prometheus as a Grafana data source
- Build a panel from a PromQL query
- Use variables to make dashboards reusable
- Apply dashboard design best practices
Step 1 β Add the Data Source
Grafana talks to many backends. To read Prometheus, add it as a data source β in the UI under Connections β Data sources, or as config-as-code:
# grafana/provisioning/datasources/prometheus.yml
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: trueπ‘ Provision, don't click
Clicking through the UI is fine to learn, but in real setups you provision data sources and dashboards from files (as above) so theyβre version-controlled and reproducible β the same GitOps mindset you use everywhere else.
Step 2 β Build a Panel
A panel is a single visualization driven by one or more queries. Create a panel, pick the Prometheus data source, and enter a PromQL query. For a request-rate graph:
sum(rate(http_requests_total[5m])) by (status)Grafana draws one line per status label. Choose a visualization type to match the data:
| Visualization | Best for |
|---|---|
| Time series | Rates and values over time (the default) |
| Stat | A single big number (e.g. current error rate) |
| Gauge | A value against a threshold (e.g. CPU %) |
| Bar gauge / Table | Comparing many labelled values at once |
Step 3 β Make it Reusable with Variables
Hard-coding a service name into every panel means one dashboard per service. Instead, define a template variable and let users pick from a dropdown.
Create a variable named service whose values come from a query, then reference it in panels with the $service syntax:
sum(rate(http_requests_total{service="$service"}[5m])) by (status)Now one dashboard covers every service β the dropdown at the top swaps $service for whatever the viewer selects.
β Panels are only as good as the query
If a panel looks wrong, 90% of the time itβs the PromQL, not Grafana. Test the query in the Prometheus UI first, then paste it into the panel.
Dashboard Design That People Actually Use
A dashboard is a communication tool. Good ones follow a few rules:
- Top-left is prime real estate β put the most important health signals there (the βis it up and healthy?β numbers).
- Follow the RED method for services: Rate, Errors, Duration β the three lines that tell you almost everything.
- Use USE for resources: Utilization, Saturation, Errors for hosts and disks.
- Set units and thresholds so a value turns red when itβs actually bad.
- Fewer panels, clearer story β 8 focused panels beat 40 you never look at.
βββββββββββββββ¬ββββββββββββββ¬ββββββββββββββ
β Req Rate β Error % β p95 Latencyβ β at-a-glance health
βββββββββββββββ΄ββββββββββββββ΄ββββββββββββββ€
β Requests/sec by status β β trends
βββββββββββββββββββββββββββββββββββββββββββ€
β Latency percentiles over time β
βββββββββββββββββββββββββββββββββββββββββββπ§ͺ Hands-on Lab
Design a Service Dashboard
Sketch the queries for a RED dashboard for a service called checkout. Write PromQL for:
- Request rate
- Error ratio (5xx as a fraction of all requests)
- Duration β p95 latency (assume a histogram
http_request_duration_seconds_bucket)
π§ Knowledge Check
What does the RED method recommend tracking for a service?
Why use a template variable like $service in a dashboard?
πΌ Interview Preparation
How do you decide what to put on a monitoring dashboard?
Summary
You can now connect Grafana to Prometheus, build panels from PromQL, parameterise dashboards with variables, and design views around RED/USE. The final piece of monitoring is being told when something breaks β so next we set up alerting.