Skip to main content

Grafana Dashboard Tutorial: Build, Customise and Alert

Updated 17 min readMarkdown

A Grafana dashboard turns raw metrics into something a human can act on at 3 a.m. When a service starts failing, nobody opens a terminal and reads a wall of numbers. They open a dashboard, and within seconds they need to know three things: what is broken, how bad it is, and whether it is getting worse. A well-built dashboard answers all three. A badly built one adds noise to an incident that is already stressful enough.

This tutorial walks you through building Grafana dashboards the way working DevOps engineers actually build them: install Grafana, connect Prometheus, build a dashboard that answers the four golden signals, template it with variables so it works across environments, wire up alerting, and store the result as code. By the end you will have a production-shaped dashboard for a web service: request rate, error rate, latency and saturation — the same shape you would build on the job.

What a Grafana Dashboard Is and How It Works

Grafana itself does not collect metrics. That surprises people who are new to observability, so it is worth stating plainly: Grafana is a visualisation and alerting layer that sits on top of a data source. The data source — Prometheus, in this tutorial — stores the time series, and Grafana queries it, draws the results, and fires alerts when a threshold is crossed. Understanding that split makes everything else in this tutorial easier, because every decision about what a panel shows is really a decision about what the underlying query asks for.

A dashboard is a collection of panels arranged in rows on a grid. Each panel runs one or more queries against a data source and visualises the result — a time series graph, a single number, a gauge, a table. Panels can be resized and rearranged, grouped into rows, and linked to other dashboards. A dashboard is not a report: it is a live view that refreshes as new data arrives, and the refresh interval you choose is part of the design.

Behind the scenes, a dashboard is a JSON document. Every panel, query, threshold and layout choice is stored as JSON, which means dashboards can be exported, version-controlled, and provisioned from files — the basis of the “dashboard as code” approach covered later in this tutorial. Grafana dashboard documentation describes the full JSON model and every panel option.

Grafana organises dashboards into folders, and access is controlled by organisations, folders and dashboard permissions. Give the whole team viewer access to the dashboards they need, editor access only to the people who build them, and admin access to almost nobody. That discipline matters more as dashboards multiply, because a dashboard that anyone can edit is a dashboard that someone will break at 2 a.m.

Before you build anything, decide what the dashboard is for. The best dashboards answer one question for one audience — the on-call engineer at 3 a.m., the team lead reviewing a release, the product manager tracking adoption. A dashboard that tries to answer everything answers nothing, because every extra panel dilutes the ones that matter.

The classic starting point for a web service is the four golden signals: latency, traffic, errors and saturation. Latency is how long requests take, traffic is how many requests arrive, errors are the share that fail, and saturation is how close your resources are to their limits. A dashboard that shows all four, at a glance, tells you whether the service is healthy or not.

Installing Grafana and Connecting Prometheus

The fastest reliable way to run Grafana for learning is Docker. One container gives you a clean install you can delete and recreate in seconds, and a named volume keeps your dashboards when the container is removed:

docker volume create grafana-data
docker run -d --name grafana \
  -p 3000:3000 \
  -v grafana-data:/var/lib/grafana \
  -e GF_SECURITY_ADMIN_USER=admin \
  -e GF_SECURITY_ADMIN_PASSWORD=admin \
  grafana/grafana-oss:latest

Open http://localhost:3000 in your browser and sign in with the default credentials, admin and admin. Grafana will ask you to change the password on first login — do it, even on a local install, because a default password on a service that eventually gets exposed to a network is how incidents start.

If you would rather install Grafana on a Linux server, Grafana Labs publishes official packages for Debian, Ubuntu and Red Hat-based distributions, and the service is managed with systemd like any other: sudo systemctl enable --now grafana-server to start it and enable it at boot, and sudo systemctl status grafana-server to check it is running. The configuration file lives at /etc/grafana/grafana.ini, and the data directory defaults to /var/lib/grafana. If you want a refresher on how services like this are managed on Linux, our Linux commands guide for DevOps engineers covers the systemctl workflow in detail.

Next you need data. A dashboard without a data source is an empty frame, so connect Prometheus before you build anything. If you followed our Prometheus and Grafana monitoring tutorial, you already have a Prometheus server scraping targets. If not, you can run one quickly with Docker:

docker run -d --name prometheus \
  -p 9090:9090 \
  prom/prometheus:v3.0.0

To add Prometheus as a data source, go to Connections, then Data sources, then Add data source, and choose Prometheus. The URL is http://localhost:9090 if Prometheus runs on the same machine, or the address of your Prometheus server if it runs elsewhere. The Prometheus data source documentation lists the full set of connection options. Click Save and test. Grafana runs a small query and reports success — if it fails, check that Prometheus is actually running and that the URL is reachable from the Grafana container, which is the most common mistake when both run in Docker.

Set a sensible default refresh interval for each dashboard. A five-minute refresh is reasonable for a dashboard you glance at occasionally; a five-second refresh is for a dashboard you stare at during an incident, and it hammers the data source. Choose the interval that matches how the dashboard is actually used.

Building Your First Dashboard Step by Step

With Grafana running and Prometheus connected, create your first dashboard. Click Dashboards, then New, then New dashboard, and add your first panel.

Start with the simplest useful panel: request rate. If your Prometheus server scrapes a web application that exposes an http_requests_total counter, the query rate(http_requests_total[5m]) gives you requests per second over a five-minute window. If you only have Prometheus scraping itself, use rate(prometheus_http_requests_total[5m]) instead; the mechanics are identical. Choose the Time series visualisation, set the panel title to “Request rate” and the unit to Requests/sec. Save the panel.

Now add a second panel for error rate. The query below divides the rate of error responses by the rate of all responses, giving you the share of requests that fail:

sum(rate(http_requests_total{status=~"5.."}[5m]))
  /
sum(rate(http_requests_total[5m]))

Set the unit to Percent (0-1) if your query returns a ratio, or Percent (0-100) if it returns a number out of a hundred — getting this wrong is the most common reason an error-rate panel shows 0.04% when the real error rate is 4%. Set the title to “Error rate” and add a threshold at 0.05 so the panel turns red when more than 5% of requests are failing.

Repeat the pattern for latency. A good latency query uses a histogram if your application exposes one: histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le)) gives you the 95th percentile latency, which is the number that matters in practice. Averages hide the slow requests that your users actually notice, while the 95th percentile shows what the slowest 5% of requests experience. Set the unit to seconds and the title to “95th percentile latency”.

Arrange the three panels in a row across the top of the dashboard. This top row is the most valuable real estate on the dashboard: it is what the on-call engineer sees first, and it should answer the three questions from the introduction — what is broken, how bad it is, and whether it is getting worse. Below it, add a second row for saturation: CPU and memory usage, disk usage, and the number of running instances. Those panels tell you why the top row looks the way it does.

Save the dashboard with a clear name, such as “Web API overview”, and add a description explaining what it covers and who it is for. A dashboard with no description is a dashboard nobody trusts, because nobody knows whether it is current or abandoned.

Panels That Actually Help: Time Series, Stat, Gauge and Table

Grafana ships with many visualisation types, and beginners often try all of them at once. Resist that. Four panel types cover almost every monitoring need, and learning when to use each one is more valuable than learning the other twenty.

The time series panel is the default and the workhorse. Use it whenever the shape of a metric over time matters: request rate, error rate, latency, CPU usage. If you cannot see the trend, you cannot tell whether a problem is getting worse or getting better, and the time series panel is the only visualisation that shows you the trend.

The stat panel shows a single number, large and unmissable. Use it for the numbers that define health right now: current error rate, requests per second, number of healthy instances. A stat panel answers “how bad is it?” at a glance, and it is the right choice for the top row of an incident dashboard, where the reader has no time to read a graph.

The gauge panel is similar to a stat panel but shows the value against a range, which makes it good for saturation metrics: CPU usage as a percentage of capacity, memory usage, disk usage, queue depth. A gauge tells you not just the number but how close you are to the limit, which is the information that matters for saturation.

The table panel is for lists: the top ten endpoints by error count, instances sorted by memory usage, the slowest queries in the last hour. Use it when the question is “which one?” rather than “how much?” — which endpoint is failing, which instance is hot, which query is slow.

Whatever visualisation you choose, apply the same discipline to thresholds. A threshold should mean something: the value above which a human needs to act. A threshold set at an arbitrary round number is decoration, and a dashboard full of decorative thresholds trains the team to ignore all of them, including the ones that matter.

Variables, Templating and Multi-Environment Dashboards

The moment you have a second environment, copy-pasting dashboards becomes a liability. You end up with a production dashboard, a staging dashboard and a development dashboard that drift apart, and a fix applied to one never reaches the others. Variables solve this: one dashboard, templated, that works for every environment.

Create a variable from the dashboard settings, under Variables. The most common type is a query variable, which runs a PromQL query and uses the results to populate a dropdown. To build an environment variable, use label_values(http_requests_total, environment), which returns every value of the environment label. To build a service variable, use label_values(http_requests_total, service). Grafana populates the dropdown from the query results, so the list stays accurate as your infrastructure changes — no manual updates when a new service appears.

Use the variable in your queries with the dollar syntax. A query that was rate(http_requests_total[5m]) becomes rate(http_requests_total{environment="$environment", service="$service"}[5m]). When you switch the dropdown, every panel updates. You can also set a variable to multi-value, which lets the reader select several environments at once and compare them on the same graph — useful when you want to see whether a problem affects production only or every environment.

Variables can depend on each other. A service variable can be filtered by the selected environment, with a query such as label_values(http_requests_total{environment="$environment"}, service), and Grafana refreshes it whenever the environment changes.

Two practical tips make variables work smoothly. First, give every variable a clear label, because the dropdown is the first thing a reader interacts with, and a variable labelled “env” with values “prod”, “staging” and “dev” is clearer than one labelled “e” with values nobody recognises. Second, set a sensible default — usually production — so the dashboard opens on the view that matters most.

Variables also make dashboards reusable across teams. A platform team can build one dashboard for HTTP services, template it by service, and hand it to every team, instead of building a slightly different dashboard for each one. That is how a small platform team supports dozens of services without drowning in dashboard maintenance.

Alerting and Dashboard as Code

A dashboard that nobody watches is a poster. Alerting is what turns it into a monitoring system. Grafana includes a built-in alerting system — Grafana Alerting — that evaluates rules against your data sources and sends notifications when a condition is met.

Create an alert rule from a panel by choosing Alert in the panel menu, or from the Alerting section in the sidebar. A rule has a query, a condition, and an evaluation interval. The classic first rule is the one from the error-rate panel: alert when the error rate exceeds 5% for five minutes. The “for five minutes” part matters — without it, a single spike triggers a page, and the team learns to ignore alerts. Set the evaluation interval to match the pace of the problem: a minute for fast-moving errors, five minutes for slower trends.

Every alert needs a runbook link and a clear summary. The alert message should say what is wrong, which service is affected, and where to look first. An alert that says “Error rate high” at 3 a.m. is a puzzle; an alert that says “Error rate on the payments API is 12%, runbook at https://example.com/runbooks/payments-errors” is a task. Write the message as if the reader has just been woken up, because they have.

Once dashboards and alerts are working, store them as code. Export a dashboard from its settings menu as JSON, commit the JSON to version control, and provision it with Grafana’s provisioning system or the API. Provisioning loads dashboard JSON from a directory on disk, so a Grafana instance that starts fresh automatically gets the dashboards your team has committed. That means dashboards survive a Grafana rebuild, changes are reviewed like code, and a dashboard that was accidentally deleted is one git revert away from being restored.

The same approach applies to alert rules, which can be provisioned from files or managed through the API. The full provisioning model is covered in Grafana’s documentation, and the investment pays off the first time a dashboard is lost and restored from version control instead of rebuilt from memory.

Common Mistakes and How to Fix Them

The most common dashboard mistake is too many panels. A dashboard with forty panels is not comprehensive, it is unreadable. If a panel has not helped anyone make a decision in the last month, delete it. A dashboard should fit on one screen without scrolling, and every panel on it should earn its place.

The second mistake is queries that are too expensive. A query that scans a huge amount of data over a long time range is slow, and a dashboard full of them is unusable during an incident, which is exactly when you need it most. Use recording rules in Prometheus to pre-compute expensive queries, keep the time range short by default, and avoid queries that return thousands of series when a dozen would do.

The third mistake is stale dashboards. A dashboard built for a service that has since changed its metrics, its labels or its architecture shows numbers that no longer mean what they say. Review dashboards regularly — quarterly is a good cadence — and delete or fix the ones that have drifted. A dashboard that shows wrong numbers is worse than no dashboard, because it creates false confidence.

The fourth mistake is ignoring time zones and time ranges. Grafana defaults to the browser’s local time zone, which means the same dashboard shows different times to engineers in different countries, and an incident timeline discussed in UTC does not match a graph drawn in local time. Set the dashboard time zone explicitly — UTC is the usual choice for teams that span time zones — and make sure the default time range is useful, usually the last hour or the last six hours rather than the last 24.

Finally, watch out for panels that look healthy because they show no data. A graph with no line can mean the metric is zero, or it can mean the query matches nothing, and those two situations are very different. Use the “No data” state deliberately: configure panels to show a clear warning when there is no data, so a missing metric is visible instead of invisible.

Frequently Asked Questions

What is the difference between Grafana and Prometheus?

Prometheus collects and stores time series metrics by scraping targets, and it has its own query language, PromQL, and a basic built-in interface. Grafana is a visualisation and alerting layer that queries Prometheus (and many other data sources) and turns the results into dashboards and alerts. You need Prometheus to have data; you need Grafana to make that data readable at a glance.

Is Grafana free to use?

Yes. Grafana open source is free under the AGPL licence and covers dashboards, data sources and alerting. Grafana Labs also offers a managed cloud service and an enterprise edition with additional features such as advanced authentication and reporting, but the open source edition is what this tutorial uses, and it is enough for the dashboards described here.

How do I share a dashboard with my team?

The simplest way is to give teammates access to the same Grafana instance with viewer or editor roles, and organise dashboards into folders so each team finds its own. For sharing outside your Grafana instance, export the dashboard as JSON and share the file, or use a snapshot, which creates a public, read-only link to a static copy of the dashboard at a point in time.

Why is my panel showing no data?

The usual causes are a wrong data source, a query that matches no series, a label value that does not exist, or a time range in which the metric was not collected. Check the query in the Explore view, where you can run it directly and see the raw results, and verify that the data source is connected and the metric name is correct.

Should I use Grafana Cloud or self-host Grafana?

Self-hosting is free and gives you full control, and it is the best choice for learning. Grafana Cloud removes the operational work — no upgrades, no backups, no availability worries — and it is the better choice for a team that wants monitoring without running another service. The dashboards you build work the same way in both, so starting self-hosted and moving later costs you nothing.

Conclusion

A good Grafana dashboard is a tool for making decisions under pressure. Build it around the four golden signals, keep the panel count small, template it with variables so one dashboard serves every environment, and wire up alerting with clear messages and runbook links. Store the result as code, review it regularly, and delete the panels that have stopped earning their place.

If dashboards are the visible part of the job, read our site reliability engineer career guide to see how dashboards and alerting fit into the wider SRE role.

Sources: Verified 2 Dec 2026. Grafana dashboard documentation: https://grafana.com/docs/grafana/latest/dashboards/ ; Prometheus data source documentation: https://grafana.com/docs/grafana/latest/datasources/prometheus/ .

About the author

  • DevOps Jobs, Cloud Tutorials & Career Guides — https://devopsjobupdates.com

No comments yet. Be the first to comment.

More from this blog