Un client signale que le parcours de paiement est lent aujourd’hui. La page d’état est verte. La latence P95 HTTP dans Prometheus est normale. Les logs montrent des 200. Le client envoie un fichier HAR : l’appel /api/v1/checkout a pris 4,3 secondes, et à cet horodatage précis vos dashboards ne montrent rien d’anormal. Les vingt minutes qui suivent, vous devinez — c’était la base de données, le prestataire de paiement tiers, une file in-process, une dépendance lente à trois sauts ? Sans traces, la réponse à « où est passé le temps dans cette requête » est toujours une devinette. Tempo est ce qui ferme cet écart : chaque requête émet un arbre de spans, vous interrogez le trace ID et voyez exactement quel span a brûlé les 3 secondes. Sur une machine AlmaLinux 9 mono-nœud avec stockage S3, le problème d’attribution de latence disparaît le jour où vous le branchez.
Ce qui se passe
Tempo stocke des données de trace — des séquences de spans horodatés et structurés liés par un trace ID commun — adossées à du stockage objet et interrogées par trace ID, par attributs (TraceQL) ou par agrégation de graphe de service. Il accepte les traces sur OTLP (HTTP et gRPC), Jaeger, Zipkin et les anciens formats thrift. Un déploiement monolithique en binaire unique tient des dizaines de milliers de spans par seconde sur une VM modeste parce que les données de trace sont append-only et que Tempo écrit des blocs de type Parquet directement dans S3 — pas d’index coûteux à maintenir comme avec le backend Cassandra/Elastic de Jaeger.
En production vous placez un OpenTelemetry Collector devant Tempo (ou plusieurs, un par environnement). Les applications envoient l’OTLP au collector, le collector regroupe et relaie vers Tempo. L’échantillonnage des traces vit dans le collector — vous échantillonnez à la bordure, pas dans l’application, donc changer le taux n’exige pas un redeploy. Tempo expose ensuite une API de requête que Grafana frappe comme une datasource. La corrélation trace-vers-logs et trace-vers-métriques dans Grafana vous laisse cliquer un span et sauter directement à la ligne de log dans Loki ou à la métrique dans Mimir, ce qui justifie tout le mal qu’on se donne pour la pile d’observabilité.
Comment vérifier
Tempo est sain :
curl -s http://10.30.0.21:3200/ready
# attendu : ready
curl -s http://10.30.0.21:3200/status/version
L’ingestion de traces fonctionne — envoyez un span synthétique sur l’endpoint OTLP HTTP :
TRACE_ID=$(openssl rand -hex 16)
SPAN_ID=$(openssl rand -hex 8)
NOW_NS=$(date +%s%N)
END_NS=$(($NOW_NS + 50000000))
curl -X POST http://10.30.0.21:4318/v1/traces \
-H 'Content-Type: application/json' \
-d @- <<EOF
{
"resourceSpans":[{
"resource":{"attributes":[{"key":"service.name","value":{"stringValue":"synthetic"}}]},
"scopeSpans":[{"spans":[{
"traceId":"${TRACE_ID}",
"spanId":"${SPAN_ID}",
"name":"GET /health",
"kind":2,
"startTimeUnixNano":"${NOW_NS}",
"endTimeUnixNano":"${END_NS}"
}]}]
}]
}
EOF
# Query it back
sleep 5
curl -s "http://10.30.0.21:3200/api/traces/${TRACE_ID}" | jq '.batches[0].scopeSpans[0].spans[0].name'
# expect: "GET /health"
Confirmer que les blocs atterrissent dans S3 :
aws --endpoint-url https://s3.fr-par.scw.cloud s3 ls s3://acme-tempo-traces/single-tenant/ \
| head -10
Le correctif
Enregistrez sous /root/setup-tempo.sh et exécutez sur la VM Tempo. Le script installe Tempo 2.5, configure l’ingestion OTLP HTTP + gRPC, pointe le stockage de blocs vers S3, monte un OpenTelemetry Collector sur le même hôte en sidecar (en production vous le mettez sur les boîtes applicatives), et met NGINX en façade pour TLS.
#!/usr/bin/env bash
set -euo pipefail
### AlmaLinux 9 Grafana Tempo + OpenTelemetry Collector installer
### Single-node, S3-backed, OTLP ingest on 4317 (gRPC) / 4318 (HTTP)
if [[ "$(id -u)" -ne 0 ]]; then
echo "Run as root."
exit 1
fi
# === EDIT ===
NODE_IP="10.30.0.21"
TEMPO_VERSION="2.5.0"
OTELCOL_VERSION="0.103.0"
S3_ENDPOINT="s3.fr-par.scw.cloud"
S3_REGION="fr-par"
S3_BUCKET="acme-tempo-traces"
S3_ACCESS_KEY="CHANGE_ME_ACCESS"
S3_SECRET_KEY="CHANGE_ME_SECRET"
PUBLIC_DOMAIN="tempo.example.com"
# =============
echo
echo "========================================"
echo "Tempo node ${NODE_IP}"
echo "========================================"
echo "==> Updating base OS"
dnf -y update
dnf -y install epel-release
dnf -y install vim curl wget chrony fail2ban dnf-automatic \
policycoreutils-python-utils lsof tcpdump bind-utils tar gzip \
iproute net-tools jq socat firewalld nginx certbot python3-certbot-nginx \
openssl htop iotop
systemctl enable --now chronyd
systemctl enable --now firewalld
echo "==> Firewall rules"
firewall-cmd --permanent --add-service=ssh
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
# OTLP ingest from app/collector boxes only — restrict source as needed
firewall-cmd --permanent --add-port=4317/tcp
firewall-cmd --permanent --add-port=4318/tcp
firewall-cmd --reload
echo "==> SELinux enforcing"
sed -i 's/^SELINUX=.*/SELINUX=enforcing/' /etc/selinux/config
setenforce 1 || true
setsebool -P httpd_can_network_connect 1
echo "==> SSH hardening"
sed -i 's|^[#[:space:]]*PermitRootLogin.*|PermitRootLogin prohibit-password|' /etc/ssh/sshd_config
sed -i 's|^[#[:space:]]*PasswordAuthentication.*|PasswordAuthentication no|' /etc/ssh/sshd_config
sshd -t && systemctl restart sshd
echo "==> fail2ban + automatic security updates"
cat > /etc/fail2ban/jail.d/sshd.local <<'FAIL2BAN'
[sshd]
enabled = true
port = ssh
backend = systemd
maxretry = 4
findtime = 10m
bantime = 1h
FAIL2BAN
systemctl enable --now fail2ban
cat > /etc/dnf/automatic.conf <<'DNFAUTO'
[commands]
upgrade_type = security
random_sleep = 900
download_updates = yes
apply_updates = yes
[emitters]
emit_via = stdio
DNFAUTO
systemctl enable --now dnf-automatic.timer
echo "==> Sysctl"
cat > /etc/sysctl.d/99-tempo.conf <<'SYSCTL'
fs.file-max = 2097152
net.core.somaxconn = 8192
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.ip_local_port_range = 10240 65535
vm.max_map_count = 262144
SYSCTL
sysctl --system
cat > /etc/security/limits.d/99-tempo.conf <<'LIMITS'
tempo soft nofile 200000
tempo hard nofile 200000
LIMITS
echo "==> Creating tempo user"
id -u tempo >/dev/null 2>&1 || useradd --system --no-create-home --shell /sbin/nologin tempo
mkdir -p /var/lib/tempo/wal /var/lib/tempo/blocks /etc/tempo
chown -R tempo:tempo /var/lib/tempo /etc/tempo
echo "==> Downloading Tempo ${TEMPO_VERSION}"
cd /tmp
wget -q "https://github.com/grafana/tempo/releases/download/v${TEMPO_VERSION}/tempo_${TEMPO_VERSION}_linux_amd64.tar.gz"
tar xzf "tempo_${TEMPO_VERSION}_linux_amd64.tar.gz"
install -o root -g root -m 0755 tempo /usr/local/bin/tempo
/usr/local/bin/tempo --version
echo "==> Writing tempo.yml"
cat > /etc/tempo/tempo.yml <<EOF
stream_over_http_enabled: true
server:
http_listen_port: 3200
grpc_listen_port: 9095
log_level: info
distributor:
receivers:
otlp:
protocols:
http:
endpoint: 0.0.0.0:4318
grpc:
endpoint: 0.0.0.0:4317
jaeger:
protocols:
thrift_http:
endpoint: 0.0.0.0:14268
zipkin:
endpoint: 0.0.0.0:9411
ingester:
trace_idle_period: 10s
max_block_duration: 5m
compactor:
compaction:
block_retention: 720h # 30 days; raise as budget allows
metrics_generator:
registry:
external_labels:
source: tempo
storage:
path: /var/lib/tempo/generator/wal
traces_storage:
path: /var/lib/tempo/generator/traces
storage:
trace:
backend: s3
s3:
bucket: ${S3_BUCKET}
endpoint: ${S3_ENDPOINT}
region: ${S3_REGION}
access_key: ${S3_ACCESS_KEY}
secret_key: ${S3_SECRET_KEY}
insecure: false
wal:
path: /var/lib/tempo/wal
pool:
max_workers: 100
queue_depth: 10000
overrides:
defaults:
metrics_generator:
processors: [service-graphs, span-metrics]
ingestion:
max_traces_per_user: 100000
rate_limit_bytes: 25000000
burst_size_bytes: 50000000
EOF
chown -R tempo:tempo /etc/tempo
echo "==> Tempo systemd unit"
cat > /etc/systemd/system/tempo.service <<'UNIT'
[Unit]
Description=Grafana Tempo
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=tempo
Group=tempo
ExecStart=/usr/local/bin/tempo -config.file=/etc/tempo/tempo.yml
Restart=on-failure
RestartSec=5s
LimitNOFILE=200000
TimeoutStopSec=60
[Install]
WantedBy=multi-user.target
UNIT
systemctl daemon-reload
systemctl enable --now tempo
echo "==> Installing OpenTelemetry Collector"
cd /tmp
wget -q "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${OTELCOL_VERSION}/otelcol-contrib_${OTELCOL_VERSION}_linux_amd64.rpm"
dnf -y install "./otelcol-contrib_${OTELCOL_VERSION}_linux_amd64.rpm"
cat > /etc/otelcol-contrib/config.yaml <<'OTEL'
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:14317
http:
endpoint: 0.0.0.0:14318
processors:
batch:
timeout: 10s
send_batch_size: 1024
memory_limiter:
check_interval: 5s
limit_mib: 1024
spike_limit_mib: 256
tail_sampling:
decision_wait: 10s
num_traces: 50000
expected_new_traces_per_sec: 1000
policies:
- name: errors
type: status_code
status_code: {status_codes: [ERROR]}
- name: slow
type: latency
latency: {threshold_ms: 500}
- name: sample-rest
type: probabilistic
probabilistic: {sampling_percentage: 5}
exporters:
otlp/tempo:
endpoint: 127.0.0.1:4317
tls:
insecure: true
service:
pipelines:
traces:
receivers: [otlp]
processors: [memory_limiter, tail_sampling, batch]
exporters: [otlp/tempo]
OTEL
systemctl enable --now otelcol-contrib
echo "==> NGINX with TLS termination for query API"
cat > /etc/nginx/conf.d/tempo.conf <<EOF
upstream tempo_http { server 127.0.0.1:3200; keepalive 32; }
server {
listen 80;
server_name ${PUBLIC_DOMAIN};
location /.well-known/acme-challenge/ { root /var/www/html; }
location / { return 301 https://\$host\$request_uri; }
}
server {
listen 443 ssl http2;
server_name ${PUBLIC_DOMAIN};
ssl_certificate /etc/letsencrypt/live/${PUBLIC_DOMAIN}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/${PUBLIC_DOMAIN}/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
proxy_read_timeout 120s;
client_max_body_size 50m;
location / {
proxy_set_header Host \$host;
proxy_pass http://tempo_http;
}
}
EOF
mkdir -p /var/www/html
nginx -t && systemctl enable --now nginx
echo "==> Waiting for Tempo /ready"
for i in {1..60}; do
if curl -fs "http://127.0.0.1:3200/ready" >/dev/null 2>&1; then break; fi
sleep 2
done
echo
echo "========================================"
echo "DONE"
echo "========================================"
echo
echo "Listeners:"
ss -lntp | grep -E ':(80|443|3200|4317|4318|9095|14317|14318|14268|9411)\b' || true
echo
echo "Send your first OTLP trace from any host:"
echo " curl -X POST http://${NODE_IP}:4318/v1/traces -H 'Content-Type: application/json' -d @trace.json"
echo
echo "Run certbot --nginx -d ${PUBLIC_DOMAIN} once DNS is pointed."
Dans Grafana, ajoutez la datasource Tempo :
# /etc/grafana/provisioning/datasources/tempo.yaml
apiVersion: 1
datasources:
- name: Tempo
type: tempo
access: proxy
url: https://tempo.example.com
jsonData:
tracesToLogsV2:
datasourceUid: loki
spanStartTimeShift: '-5m'
spanEndTimeShift: '5m'
tags: [{key: 'service.name', value: 'service'}]
tracesToMetrics:
datasourceUid: mimir
tags: [{key: 'service.name', value: 'service'}]
nodeGraph:
enabled: true
serviceMap:
datasourceUid: mimir
Côté application, pointez votre SDK OTLP sur le collector — jamais directement sur Tempo. Le collector gère échantillonnage, batching et back-pressure pendant les pics d’ingestion. Un exemple minimal Node.js :
// app/tracing.js
const { NodeSDK } = require('@opentelemetry/sdk-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-grpc');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const sdk = new NodeSDK({
serviceName: 'checkout-api',
traceExporter: new OTLPTraceExporter({
url: 'grpc://otelcol.internal:14317',
}),
instrumentations: [getNodeAutoInstrumentations()],
});
sdk.start();
Le serviceName devient le regroupement dominant dans Tempo — gardez-le stable entre déploiements, sinon votre graphe de service se fragmente. Surveillez tempo_distributor_spans_received_total et tempo_distributor_spans_received_bytes_total pour repérer les pics d’ingestion. Si tempo_ingester_failed_flushes_total monte, S3 rejette les écritures (presque toujours des credentials ou une politique de bucket).
Faites tourner le traçage distribué sur la compute infogérée Stack Harbor avec politiques de cycle de vie sur le stockage objet et câblage trace-vers-logs réglé pour votre pile — ou parlons-en si vous souhaitez la couche d’observabilité livrée comme service.