StatsD vs Prometheus: どちらのメトリクスアプローチ?
StatsD は小さな集約デーモンを持つ、シンプルな push ベースのメトリクスプロトコルです。Prometheus は豊富なクエリ言語を備えた、次元的な pull ベースの監視システムです。
StatsD はアプリケーションが UDP 経由で counter や timer を fire-and-forget でデーモンに送り、それが集約して転送する仕組みで、次元性よりもシンプルさを重視します。Prometheus はラベル付きメトリクスをスクレイプし、PromQL、アラート、大きなエコシステムを提供します。StatsD はシンプルさと容易なアプリ計装で勝り、Prometheus は次元的なクエリ、アラート、エコシステムで勝ります。
| StatsD | Prometheus | |
|---|---|---|
| モデル | push (UDP) | pull (scrape) |
| 次元 | 限定的 (タグは様々) | 一級のラベル |
| クエリ | 下流の store 経由 | PromQL |
| アラート | 外部 | 組み込み |
| 最適な用途 | シンプルなアプリメトリクス | 次元的な監視 |
ユースケースとモデル
StatsD は、アプリが scrape エンドポイントを公開せずにシンプルなメトリクスを push する、素早いアプリケーション計装に適しています。Prometheus は、ラベル、強力なクエリ、組み込みのアラートを備えた次元的な監視に適しています。statsd_exporter は StatsD メトリクスを Prometheus にブリッジできます。
運用と CI への適合
StatsD はきわめて軽量です。Prometheus はより完全なシステムですが、それでも運用はシンプルです。どちらも CI でエフェメラルなインスタンスに対して実行され、より高速なマネージドランナーがメトリクスパイプラインの統合テストを短縮します。
Decide with your own numbers, not a feature table
Feature comparisons age badly and rarely decide anything, because both tools in a mature category can do the job. What differs is how each behaves on your repository, and that takes one afternoon to measure.
# time a cold install with each candidate, cache cleared
hyperfine --prepare "rm -rf node_modules" --warmup 1 \
"<tool-a> install" "<tool-b> install"
# and the thing CI actually pays for: a cold run with no local cache
docker run --rm -v "$(pwd):/w" -w /w node:22 sh -c "<tool> install"What actually changes when you switch
- Lockfile format. A switch is a one-way door for anyone still on the old tool until everyone migrates, so plan it as a single coordinated change.
- Resolution strictness. Tools differ on whether an undeclared transitive import works, and the stricter one will surface latent bugs as new failures.
- CI cache configuration. The cache path and key differ per tool; carrying over the old ones silently disables caching.
- Everyone on the team and every runner must move together. Pin the version so they cannot drift.
結論
きわめてシンプルな push 計装が欲しいなら StatsD。次元的なメトリクス、PromQL、組み込みのアラートが欲しいなら Prometheus。多くの場合、両方の利点を得るために exporter を介して StatsD を Prometheus にブリッジします。