メインコンテンツまでスキップ

Prometheus連携

TSEの前段には Prometheus互換アダプタが載っています。別途Prometheusサーバなしで 収集(remote_write)と可視化(PromQL) をPrometheusエコシステムのまま利用できます。

[Prometheus · Grafana Agent] --remote_write--> TSE --> Cassandra
[Grafana (Prometheus 데이터소스)] --PromQL--> TSE
別プロセスではありません

アダプタはTSEのJetty内で 同じプロセスとして 動作します。起動するものも、ポートを追加で開く 必要もありません — パスが/prometheus で分かれるだけです(TSEネイティブAPIは/api/v1/*)。 認証もTSEのBasic Authをそのまま使用します。

1. 値をプッシュする — remote_write​

prometheus.yml またはGrafana Agentの設定に次のように記述します。

remote_write:
- url: http://<TSE 호스트>:7800/prometheus/api/v1/write
basic_auth:
username: tse
password: "<PP_TSE_PASSWORD>"

本文は snappy圧縮 + protobuf(remote_write 1.0)で、Prometheus・Agentが自動で 処理します。成功すると204、本文が不正な場合は400(再試行なし)、一時的な障害なら 500(再試行)です。NaN と±Inf は 保存段階で破棄されます。

2. Grafanaで表示する​

データソースタイプを Prometheus に選択し、次のように入力します。

項目値
URLhttp://<TSE 호스트>:7800/prometheus
AccessServer (proxy)
AuthBasic auth — tse / <PP_TSE_PASSWORD>
HTTP MethodPOST推奨

「Save & Test」を押すと、Grafanaは/prometheus/api/v1/status/buildinfo でPrometheus であることを認識します。以降はパネルで PromQLをそのまま 使用できます。

バンドル PlantPulse Dashboardとは異なるパスです

TSEには専用データソースプラグインを使用するバンドル PlantPulse Dashboardも あります。どちらかを選択すればよいです — PromQLに慣れているならこちら、既に作成済みの 事前ダッシュボードを使用するならバンドル側です。

3. どのようにマッピングされるか​

PrometheusTSE
__name__ ラベルメトリクス名
その他のラベルタグ
サンプル (ts_ms, float64)DataPoint(double, ms)

Prometheusの命名規則([a-zA-Z_:][a-zA-Z0-9_:]*)はTSEの規則と互換性があり、損失なく 移行されます。

4. エンドポイント​

すべて/prometheus 配下にあり、Prometheus HTTP API規約({"status":"success","data":…})に従います。

メソッド・パス用途
POST /prometheus/api/v1/writeremote_write受信
GET・POST /prometheus/api/v1/query即時クエリ
GET・POST /prometheus/api/v1/query_range範囲クエリ(start・end・step)
GET /prometheus/api/v1/labelsラベル名一覧
GET /prometheus/api/v1/label/{name}/valuesラベル値一覧
GET・POST /prometheus/api/v1/seriesシリーズマッチング(match[])
GET /prometheus/api/v1/status/buildinfoGrafana認識用

時間はUnix秒(小数可)またはRFC3339、step は15s・1m・1h・500ms または単位なし秒。 応答のタイムスタンプは 秒、値は 文字列 です(Prometheus規約)。

5. 対応しているPromQL​

カテゴリ対応内容
セレクタbare · マッチャー(= != =~ !~) · __name__ マッチャー · rangeセレクタ([5m]、単位ms s m h d w y)
算術数値リテラル · 単項 - · 括弧 · + - * / (scalar∘scalar, vector∘scalar, vector∘vector 1-to-1)
比較== != > < >= <= (+ bool)
関数rate irate increase delta · abs clamp_min clamp_max · histogram_quantile
集約sum avg min max count + by/without · topk bottomk
rate(errors[5m]) / rate(total[5m])
topk(5, sum(rate(req_total[5m])) by (path))
histogram_quantile(0.95, rate(latency_seconds_bucket[5m]))

6. 非対応のもの — 静かに誤らず、400で拒否します​

カテゴリ非対応
ベクトルマッチングon(…) · ignoring(…) · group_left · group_right
集合演算and · or · unless
時間関数*_over_time · predict_linear · holt_winters
変形subquery(expr[5m:1m]) · @ 修飾子 · offset
その他scalar() vector() label_replace() label_join() sort() sort_desc() absent()
プロトコルremote_read · remote_write 2.0 · exemplars · native histogram
非対応のものは「誤った値」ではなく「エラー」として返ります

非対応構文は400 {"status":"error","errorType":"bad_data",…} で遮断されます。 静かにそれらしい数値を返さないということで、ダッシュボードが 黙って嘘をつく ことは ありません。

7. 微妙に異なる点​

完全なPrometheusではなく 互換アダプタ です。実用上はたいてい問題になりませんが、 値を精密に比較する際には知っておく必要があります。

項目どのように異なるか
rate・increase 外挿観測区間をrange全体で 線形外挿 します(Prometheusの境界外挿キャップは未実装) — 区間境界で微妙な差
rangeウィンドウ[t-range, t] 両端を含む(Prometheusは左開区間)。instantセレクタのlookbackは (t-5m, t] で 同一 でデフォルト5分
/label/<name>/values__name__ は正確ですが、その他のラベルは グローバルタグ値で過大近似 します — オートコンプリート用には十分
scalar比較常に0・1で評価します(Prometheusはbool を要求)。3 > 2 がそのまま 1

関連項目​