logo
logo
logo
logo
logo
logo

Jul 23, 2025

Jul 23, 2025

Jul 23, 2025

Jul 23, 2025

5 Grafana in Docker examples to get started with metrics, logs, and traces

5 Grafana in Docker examples to get started with metrics, logs, and traces

5 Grafana in Docker examples to get started with metrics, logs, and traces

5 Grafana in Docker examples to get started with metrics, logs, and traces

5 Grafana in Docker examples to get started with metrics, logs, and traces

5 Grafana in Docker examples to get started with metrics, logs, and traces

by Przemysław Hejman

Grafana was born from engineers’ love of open-source flexibility – just download, deploy, and dive in. It quickly became an industry standard for visualizing metrics and logs, emerging as a web-based alternative to Kibana with support for diverse data sources beyond Elasticsearch. (We previously covered its origins in Kibana vs Grafana.)

Yet today, the vendors’ focus on cloud-first experiences can feel a bit restrictive, making it less straightforward to simply experiment locally. For instance, if you search for Grafana installation, chances are you’re going to face:

  • OS-specific installation docs (e.g., Linux package managers or Homebrew for macOS)

  • Deployment instructions for Kubernetes

  • Advertising of Grafana Cloud – hosted service managed by Grafana Labs 🙃

But Grafana is open source – shouldn’t it be easy to just take it for a spin?

In this guide, we’ll go back to basics and show you how effortless – and enjoyable – it is to play around with Grafana using Docker, right from your own machine. Everything will run locally within Docker containers: no need to install any system packages, no networking issues. Just a simple fire-and-forget setup.

As we proceed, I encourage you to clone our repository (link) containing all examples shown here, and follow along. Each example is neatly organized into its own directory with a dedicated README, necessary files, and clear instructions. All you need is Docker installed and running on your machine.

Example 1: Run vanilla Grafana with Docker (standalone setup)

If we just want to run plain Grafana with no other services, it is as simple as executing a single command: 

docker run -i -t --rm -p 3000

… and there you have it! Grafana UI is ready at http://localhost:3000. Default username and password are admin/admin, you will be also prompted to change password (which can be skipped).

Grafana Labs has done a really great job with its Docker image configurability, which can be done via environment variables and mounted volumes. We are going to explore that further, but for instance, if you’d like to specify your own default login credentials, simply do:

docker run -i -t --rm -p 3000:3000 \
-e GF_SECURITY_ADMIN_USER=me@example.com \
-e GF_SECURITY_ADMIN_PASSWORD

Grafana’s rich plugin ecosystem is one of its core strengths. In order to preinstall any plugin in your Grafana Docker container, you can pass a dedicated environment variable to your container:

GF_INSTALL_PLUGINS

From here, you can configure any data source of your choice – a database or an external service (e.g. GitHub API) – and start exploring. 

Of course, the bare installation doesn’t give us much to play around with, so the next examples are going to include complementary containers, feeding sample data into the system.

Example 2: Visualize Prometheus metrics in Grafana

This example demonstrates a common use case for Grafana: displaying system metrics. Grafana is only a dashboarding and data visualization tool, so data sources must be configured separately. One of the most common tools for collecting and storing metrics is Prometheus, a powerful, time-series database designed specifically for this purpose. Prometheus can also run as a cron-like metrics collector, fetching data from various systems.

Navigate to 02_metrics_with_prometheus directory and execute:

You should be now able to access the Grafana UI at http://localhost:3000. This docker-compose command creates 2 additional services:

  1. Prometheus, our metrics store and collector  

  2. A metrics_generator container, which exposes an endpoint (http://localhost:9100/metrics) containing system metrics. We’ve used a widely adopted node-exporter Docker image.

Prometheus periodically calls metrics_generator API (see the prometheus.yml configuration file) and stores the results, making them available to query and visualize  in Grafana.

You may also notice that the Grafana container has a mounted directory named provisioning which contains pre-configured Prometheus data source and a basic dashboard so that you don’t have to click through the UI as much. If you navigate to Dashboards or Data sources sections, you’ll see that both are preconfigured.

Grafana recently introduced a useful feature called Drilldown enabling you to quickly explore data from your sources without manually configuring a dashboard. For metrics, it provides an instant overview simply through a collection of  histograms, which is particularly useful.


Example 3: Analyze logs in Grafana with Loki

Let’s move to another common Grafana use case: log visualisation. The most “native” tool within Grafana’s ecosystem is Loki,  an open source log aggregation system designed and developed by Grafana Labs. We’re going to spin up a Loki instance to store sample log lines.

Navigate to directory named 03_logs_with_loki and start all the containers with

Our analysed logs will be flowing from a small docker container named log-generator. This is a tiny program written in Go, which uses Loki’s REST API to push the log data. Of course, there are many different ways to ingest log data to Loki (such as Promtail).To keep the example simpler though, we decided not to add any extra containers and stick to Loki’s ingest API.

 

Example 4: Investigate distributed traces in Grafana with Tempo

In this example, we explore Grafana’s distributed tracing capabilities.. In complex systems architecture, where single user action triggers many interactions between separate components (e.g. independent microservices), identifying problems becomes a real challenge. Visualising traces (e.g. sequences of service calls linked to a single HTTP request) is an effective way to tackle this. Luckily for us, Grafana can help us with that too.

As before, proceed to the next directory 04_traces_with_tempo and start all the containers with: 

This example will take you through analysing traces. We’ll spin up Tempo, which is an OSS distributed tracing backend from Grafana Labs. Additionally, a tracing client container will be created to feed Tempo with sample data

There’s no pre-configured dashboard here. Instead, we’d like to encourage you to either use Drilldown > Traces or Explore tabs, both of which offer neat interfaces for trace investigation.


Example 5: Continuous profiling in Grafana with Pyroscope

The fifth example showcases Grafana’s continuous profiling support. Profiling analyzes a program’s runtime behavior, such as CPU or memory usage across call stacks. By briefly looking at applications' flame graphs, users can identify functions causing performance issues. Continuous profiling captures data from a live application, eliminating the need to reproduce issues in a lab environment.

Let’s see it in action. Navigate to the last directory 05_profiling_with_pyroscope and run 

In this example we’ll set up Pyroscope, Grafana’s aggregator for continuous profiling data. Besides running the Pyroscope docker container, we’ll also need an instrumented application that sends profiling data – the sample_app directory contains its source code. Please give it some time before the data is available for browsing. Navigate to Drilldown > Profiles to view flame graphs and related metrics.


Conclusion: Next steps for your Grafana setup

We hope these examples gave you a simple and helpful starting point for your Grafana journey. From here, you’re ready to dive deeper into creating custom dashboards, exploring different data sources, and incorporating Grafana into your own infrastructure.

Did you find this helpful? Do you know other quick ways to quickly run a PoC of a service like Grafana? We’re eager to know! Share your thoughts on Reddit or LinkedIn.

Table of Content

Title
line

Table of Content

Title
line

Table of Content

Title
line

Table of Content

Title
line

Stay tuned for future releases and more!

© Quesma Inc. 2025

Stay tuned for future releases and more!

© Quesma Inc. 2025

Stay tuned for future releases and more!

© Quesma Inc. 2025

Stay tuned for future releases and more!

© Quesma Inc. 2025

Stay tuned for future releases and more!

© Quesma Inc. 2025

Stay tuned for future releases and more!

© Quesma Inc. 2025