Grafana

See everything. Understand everything.

Data is useless if you can't understand it. Numbers in a spreadsheet don't tell a story. But a well-designed dashboard? That tells you everything at a glance.

That's Grafana. It takes the metrics from your systems — servers, applications, databases, IoT devices, whatever — and turns them into dashboards that actually make sense. It's the tool you didn't know you needed until you have it.

And here's the best part: it's free and open source. Run it yourself. Own your data. Visualize anything.

What Can Grafana Do?

Short answer: visualize time-series data. Long answer: pretty much anything involving metrics, logs, and traces.

Grafana connects to almost anything: Prometheus, InfluxDB, Elasticsearch, MySQL, PostgreSQL, Graphite, CloudWatch, Stackdriver, and dozens more.

Installing Grafana

Let's get Grafana running. I'll show a few options, starting with Docker because it's the easiest.

The Docker Way

docker run -d \
  --name grafana \
  -p 3000:3000 \
  -v grafana_data:/var/lib/grafana \
  grafana/grafana:latest

Wait a moment, then visit http://localhost:3000. Default login is admin / admin. You'll be prompted to change your password.

Installing on a Server

For a permanent installation on Debian/Ubuntu:

# Install dependencies
sudo apt install -y apt-transport-https software-properties-common

# Add Grafana repository
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -

# Install Grafana
sudo apt update
sudo apt install grafana

# Start and enable
sudo systemctl start grafana-server
sudo systemctl enable grafana-server

Grafana runs on port 3000 by default. Visit http://your-server:3000.

Pro tip: Run Grafana behind a reverse proxy (nginx or Apache) with HTTPS. Then use authentication providers (OAuth, LDAP) for team access.

Your First Dashboard

Let's build something. I'll assume you're connecting to Prometheus — if you're using something else, the concepts are the same.

Step 1: Add a Data Source

  1. Click the gear icon (Configuration) in the sidebar
  2. Select "Data Sources"
  3. Click "Add data source"
  4. Select "Prometheus"
  5. Enter your Prometheus URL (e.g., http://localhost:9090 for local)
  6. Click "Save & Test"

Step 2: Create a Dashboard

  1. Click the "+" icon in the sidebar
  2. Select "Dashboard"
  3. Click "Add new panel"

In the panel editor:

Click "Apply" in the top right. You've got a graph.

Step 3: Add More Panels

Click "Add panel" again. Try these queries:

# Memory usage
node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes

# Disk usage
100 - (node_filesystem_avail_bytes{mountpoint="/"} / node_filesystem_size_bytes{mountpoint="/"} * 100)

# Network traffic
rate(node_network_receive_bytes_total[5m])
rate(node_network_transmit_bytes_total[5m])

# Request rate (if you have a web server)
rate(http_requests_total[5m])

Arrange panels in a grid. Add titles. Configure units (bytes, seconds, percentages). This is your dashboard now.

Step 4: Save

Click the save icon (or press Ctrl+S). Give your dashboard a name. Now it's saved and you can access it from the sidebar.

Visualization Types

Grafana has more visualization options than you can shake a stick at. Here's when to use each:

Don't overcomplicate. Usually, a time series and some stat panels tell the story best.

Variables: Dynamic Dashboards

One of Grafana's most powerful features is variables. A variable lets users select values (like a server name or service) and the whole dashboard updates.

To add a variable:

  1. Go to Dashboard Settings (the gear icon when viewing a dashboard)
  2. Click "Variables"
  3. Click "Add variable"

Configure it like this:

Now in your panel queries, use $server instead of hardcoding values:

node_cpu_seconds_total{instance="$server", mode="idle"}

Now users can select which server to view from a dropdown. One dashboard, multiple servers.

Pro tip: Use variables to create "drill-down" dashboards. Select an application, see its metrics. Select a region, see regional stats. Make one dashboard work for everything.

Alerts: Know Before Things Break

Grafana isn't just for looking at pretty graphs. It can alert you when things go wrong.

Setting Up Alerts

  1. Edit a panel
  2. Click the "Alert" tab
  3. Click "Create Alert"
  4. Configure conditions

Example alert rule:

This fires when the metric stays above 90 for 5 minutes.

Notification Channels

Where should alerts go? Configure notification channels in Configuration → Notification Channels:

Pro tip: Don't alert on everything. Alert fatigue is real. Only alert on things that genuinely need attention.

The Grafana Ecosystem

Grafana isn't just Grafana anymore. It's a whole suite of observability tools:

Prometheus

The go-to metrics database. Scrapes targets, stores time series, powerful query language. If you're monitoring anything, start with Prometheus.

Loki

Log aggregation done right. Unlike Elasticsearch, Loki indexes just the labels, not the full log content. It's cheaper and faster for most use cases. Integrates perfectly with Grafana — see logs right next to your metrics.

Tempo

Distributed tracing. See how a request flows through your microservices. Click a trace in Grafana and see exactly where time was spent.

Mimir

Long-term storage for Prometheus. If you need to keep metrics for months or years, Mimir scales horizontally and handles Petabytes of data.

OnCall

Incident management. On-call schedules, escalation policies, automatic paging. Now Grafana does the whole observability stack.

Dashboards as Code

Clicking around in the UI is fine for learning, but for production, you want your dashboards in version control.

Export JSON

Every dashboard can be exported as JSON. Share it, commit it to Git, import it elsewhere.

Provisioning

Grafana can auto-provision dashboards from files. Put JSON files in /etc/grafana/provisioning/dashboards/ (or the docker equivalent):

# provisioning/dashboards/dashboards.yaml
apiVersion: 1

providers:
  - name: 'My Dashboards'
    folder: 'Ops'
    type: file
    options:
      path: /etc/grafana/provisioning/dashboards

Now your dashboards are infrastructure as code. Review changes in pull requests. Roll back if something breaks.

Grafonnet

For ultimate control, use Grafonnet — a Jsonnet library for generating Grafana dashboards. Write code that produces dashboards. Templates, loops, abstractions. It's like Terraform for dashboards.

Real-World Dashboard Ideas

Need inspiration? Here are dashboards I build on every project:

System Overview

Application Health

Business Metrics

Database

Styling and Theming

Grafana dashboards can be beautiful. Or they can be information-dense and ugly. Your choice.

Tips for better dashboards:

Wrapping Up

Grafana transforms your understanding of systems. What was once abstract numbers becomes clear patterns. What was once "something seems slow" becomes "this endpoint is 200ms slower than yesterday."

Start simple. One server, basic metrics. Then add more. Add alerts. Add logs. Add traces. Before you know it, you've got full observability.

And it all runs on your infrastructure. Your data. Your dashboards.

That's the way it should be.

The revolution will not be proprietary.

// Comments

Leave a Comment