Adding Grafana Tempo to a server involves three main stages: deploying the Tempo server, instrumenting your applications to send trace data, and configuring a visualization tool like Grafana to query and display the traces.
This process allows for robust distributed tracing, providing deep insights into the performance of your microservices and applications.
Part 1: Deploying the Tempo server
Before collecting traces, you must first install and configure the Tempo backend. For a single server, the most straightforward method is to run Tempo as a single binary or in a Docker container.
Step 1: Download and install Tempo
Method A: Single binary (for Linux)
-
Download the latest Tempo binary from the official GitHub releases page using
wget.shwget https://github.com/grafana/tempo/releases/download/v2.8.1/tempo_2.8.1_linux_amd64.tar.gzUse code with caution.
-
**Extract the archive.**sh
tar -xvf tempo_2.8.1_linux_amd64.tar.gzUse code with caution.
-
Move the binary to your system path for easy access.sh
sudo mv tempo /usr/local/bin/Use code with caution.
Method B: Docker container (Recommended for testing and production)
-
Ensure Docker is installed on your server.
-
Use a
docker-compose.yamlfile for a simple setup that includes Tempo, Grafana, and Prometheus. This provides an end-to-end observability stack out of the box.yaml# docker-compose.yaml version: "3" networks: backend: services: tempo: image: grafana/tempo:latest command: -config.file=/etc/tempo.yaml volumes: - ./tempo.yaml:/etc/tempo.yaml - ./tempo-data:/tmp/tempo ports: - "3200:3200" # Tempo gRPC - "4317:4317" # OTLP gRPC - "4318:4318" # OTLP HTTP networks: - backendUse code with caution.
-
Run
docker-compose up -dto start the services.
Step 2: Configure the Tempo server
Tempo requires a YAML configuration file to define its behavior. For a local installation, a minimal configuration is sufficient.
-
Create a
tempo.yamlfile in a designated directory (e.g.,/etc/tempo). -
Add the following configuration for a basic, monolithic setup using local storage.yaml
server: http_listen_port: 3200 distributor: receivers: otlp: protocols: grpc: http: ingester: trace_idle_period: 10s max_block_duration: 5m compactor: compaction: block_retention: 1h storage: trace: backend: local local: path: /tmp/tempo/tracesUse code with caution.
server: Defines the HTTP listening port for Tempo.distributor: Configures the receivers that accept trace data. Here, we enable OpenTelemetry Protocol (OTLP) via gRPC and HTTP, which is the recommended approach.storage: Specifies where Tempo stores trace data. For production, you should replace thelocalbackend with a more robust, scalable option like AWS S3, GCS, or an S3-compatible object store.
Step 3: Run Tempo as a service
For a production environment, running Tempo as a systemd service ensures it starts on boot and restarts automatically if it fails.
-
Create a
systemdservice file at/etc/systemd/system/tempo.service.sh[Unit] Description=Grafana Tempo After=network.target [Service] Type=simple ExecStart=/usr/local/bin/tempo --config.file=/etc/tempo/tempo.yaml Restart=on-failure [Install] WantedBy=multi-user.targetUse code with caution.
-
Reload the
systemddaemon, enable the service, and start it.shsudo systemctl daemon-reload sudo systemctl enable tempo.service sudo systemctl start tempo.serviceUse code with caution.
-
Verify that Tempo is running using
systemctl status tempo.service.
Part 2: Instrumenting applications with OpenTelemetry
Once Tempo is deployed, you need to instrument your applications to collect trace data and export it to your Tempo server. This is typically done using the OpenTelemetry SDKs and collector.