Skip to content

OTEL collector — алерт при дропе spans из очереди

OTEL collector перегружен — `otelcol_exporter_send_failed_spans` растёт. Трейсы теряются, debug по продакшну ослеп. Backend-tracing-бекенд не покажет gap.

Рецепт

bash
#!/usr/bin/env bash
# /etc/cron.d/otel-drops
# */5 * * * * root /opt/otel-drops.sh

# OTEL collector exposes Prometheus metrics on :8888 by default
URL=${OTEL_METRICS:-http://localhost:8888/metrics}
THRESH=${THRESH:-100}                 # spans dropped / 5 min
STATE=/var/lib/otel-drops.state

NOW=$(curl -fsS "$URL" | awk '/^otelcol_exporter_send_failed_spans/ && !/#/ {sum += $2} END {print int(sum)+0}')
PREV=$(cat "$STATE" 2>/dev/null || echo 0)
echo "$NOW" > "$STATE"

DELTA=$((NOW - PREV))

if [ "$DELTA" -gt "$THRESH" ]; then
  curl -fsS "$HEARTBEAT_URL" --data "dropped=$DELTA,window=5m"
  exit 2
fi
echo "OK ($DELTA spans dropped / 5m)"

То же самое в Enterno.io

Подключите Enterno heartbeat с retention — сможете коррелировать «именно при пиках трафика дропают spans» и решить bigger collector vs sampling.

Настроить HTTP monitor → ← Все рецепты

Похожие рецепты

Prometheus сам жив, но один из targets (`up==0`) — данные перестали течь, графики пустые, alertmanager-правила, основанные на этом target, не fire-ят (нет данных = нет алерта).