There is a specific kind of anxiety that comes with deploying a new feature to production and relying solely on static logs to tell you if things are breaking. In my experience, by the time a log entry alerts you to a spike in 500-errors, your users have already left. That’s why I shifted my entire monitoring stack toward live telemetry. In this real-time data visualization with Grafana tutorial, I’m going to show you exactly how to move from blind guessing to crystal-clear visibility.

Grafana has become the industry standard for a reason: it doesn’t care where your data lives, as long as it can query it. Whether you’re monitoring server metrics or business KPIs, the goal is the same—reducing the Mean Time to Detection (MTTD). If you’re debating which tool to use for your logs, you might want to check out my comparison of Grafana vs Kibana for log visualization to see which fits your specific use case better.

Prerequisites

Before we dive into the configuration, ensure you have the following ready. I’ve tested this setup on Ubuntu 22.04, but it works similarly on macOS or Windows via Docker.

Step-by-Step Setup

Step 1: Deploying the Stack with Docker

To get everything running in under two minutes, I recommend using a docker-compose.yml file. This ensures your Grafana instance can talk to your Prometheus instance over the internal Docker network.

version: '3.8'
services:
  prometheus:
    image: prom/prometheus:latest
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
    ports:
      - "9090:9090"

  grafana:
    image: grafana/grafana:latest
    ports:
      - "3000:3000"
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=admin_password_here
    depends_on:
      - prometheus

Run docker-compose up -d and navigate to http://localhost:3000. Log in with the default credentials (admin/admin) or the password you specified in the environment variable.

Step 2: Connecting Your Data Source

Once inside the Grafana UI, you need to tell the platform where your data lives. As shown in the image below, you’ll head to the Connections menu to link Prometheus.

Go to ConnectionsData SourcesAdd data source. Select Prometheus. For the URL, since we are using Docker, enter http://prometheus:9090. Click “Save & Test”. If you see a green checkmark, you’re connected.

Grafana Data Source configuration screen showing Prometheus setup
Grafana Data Source configuration screen showing Prometheus setup

Step 3: Creating Your First Real-Time Panel

Now for the actual visualization. Click the + icon in the top right and select Dashboard, then Add visualization.

In the query editor, select your Prometheus data source. To visualize something real-time, try a basic query like up (which shows if your targets are online) or node_cpu_seconds_total if you have the Node Exporter installed. Set the time range in the top right corner to Last 5 minutes and set the refresh interval to 5 seconds. This is what transforms a static chart into a real-time monitor.

Step 4: Optimizing for Readability

A dashboard with too many lines is just noise. To make your data actionable, I use these three rules:

Pro Tips for Production Dashboards

After managing several production clusters, I’ve learned a few things the hard way:

Troubleshooting Common Issues

Issue Likely Cause Solution
“Data source not found” DNS resolution in Docker Ensure both containers are on the same network; use service name instead of localhost.
Gaps in the line chart Scrape interval mismatch Adjust the “Min Step” in Grafana to match your Prometheus scrape interval.
High CPU on Browser Too many refresh intervals Increase refresh rate from 1s to 10s or use the “Streaming” feature if supported.

What’s Next?

Now that you have a basic real-time setup, the next step is making it proactive. I recommend exploring Loki for log aggregation to complement your metrics. While Prometheus tells you that something is wrong, Loki tells you why it’s wrong. If you’re looking to scale your automation, check out my other guides on development tools and productivity hacks here on ajmani.dev.