RousselTMLEARNING

Observabilité

Installer Grafana Tempo (Docker Compose, binaire et Helm)

Installer Grafana Tempo : configuration tempo.yaml, Docker Compose avec Grafana et Prometheus, ports OTLP, vérifications, installation du binaire et du chart Helm.

1. Configuration minimale #

Monolithique avec stockage local.

tempo.yaml #

# tempo.yaml
stream_over_http_enabled: true

server:
  http_listen_port: 3200
  log_level: info

distributor:
  receivers:
    otlp:
      protocols:
        grpc:
          endpoint: "0.0.0.0:4317"
        http:
          endpoint: "0.0.0.0:4318"

ingester:
  max_block_duration: 5m          # petits blocs pour tester rapidement

compactor:
  compaction:
    block_retention: 48h

storage:
  trace:
    backend: local
    wal:
      path: /var/tempo/wal
    local:
      path: /var/tempo/blocks
Ports de Tempo
4317/4318 pour l'ingestion, 3200 pour la lecture.

2. Docker Compose #

Tempo, Prometheus et Grafana.

docker-compose.yml #

services:
  tempo:
    image: grafana/tempo:latest
    command: ["-config.file=/etc/tempo.yaml"]
    volumes:
      - ./tempo.yaml:/etc/tempo.yaml
      - tempo-data:/var/tempo
    ports: ["3200:3200", "4317:4317", "4318:4318"]

  prometheus:
    image: prom/prometheus:latest
    command: ["--config.file=/etc/prometheus/prometheus.yml", "--web.enable-remote-write-receiver", "--enable-feature=exemplar-storage"]
    ports: ["9090:9090"]

  grafana:
    image: grafana/grafana:latest
    ports: ["3000:3000"]
    environment:
      GF_AUTH_ANONYMOUS_ENABLED: "true"
      GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
    volumes:
      - ./datasource.yml:/etc/grafana/provisioning/datasources/tempo.yml

volumes:
  tempo-data: {}
# datasource.yml
apiVersion: 1
datasources:
  - name: Tempo
    type: tempo
    url: http://tempo:3200
    jsonData:
      nodeGraph: { enabled: true }
      serviceMap: { datasourceUid: prometheus }
docker compose up -d
curl -s http://localhost:3200/ready            # doit répondre : ready
curl -s http://localhost:3200/status/version
curl -s http://localhost:3200/api/echo         # echo

3. Envoyer une première trace #

Sans écrire de code.

telemetrygen #

docker run --rm --network host \
  ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:latest \
  traces --otlp-insecure --otlp-endpoint localhost:4317 --traces 20 --child-spans 3 --service demo-service

# Récupérer le TraceID dans les logs ou rechercher via l'API
curl -s "http://localhost:3200/api/search?q=%7B%20resource.service.name%20%3D%20%22demo-service%22%20%7D&limit=3" | jq '.traces[] | {traceID, rootTraceName, durationMs}'
curl -s http://localhost:3200/api/traces/<TRACE_ID> | jq '.batches | length'

4. Binaire et Kubernetes #

Autres installations.

Binaire systemd #

curl -LO https://github.com/grafana/tempo/releases/latest/download/tempo_linux_amd64.tar.gz
tar xzf tempo_linux_amd64.tar.gz && sudo install tempo /usr/local/bin/
sudo useradd --system --no-create-home tempo && sudo mkdir -p /var/tempo /etc/tempo && sudo chown tempo: /var/tempo
tempo -config.file=/etc/tempo/tempo.yaml -config.verify=true      # vérifier la configuration

Helm #

helm repo add grafana https://grafana.github.io/helm-charts && helm repo update
# Monolithique
helm install tempo grafana/tempo -n tracing --create-namespace
# Distribué (production)
helm install tempo grafana/tempo-distributed -n tracing --create-namespace -f values-prod.yaml
kubectl -n tracing get pods
kubectl -n tracing port-forward svc/tempo 3200:3200
Erreur Courante : Le stockage local ne convient qu'aux tests : en production configurez un stockage objet (voir l'article sur le stockage) et au moins 3 ingesters avec replication_factor: 3.

Pour aller plus loin