Skip to content
このページは AI で翻訳されており、不正確な表現が含まれる場合があります。GitHub で改善にご協力ください。

監視メトリクス(Prometheus / Grafana) ​

Gately は /api/metrics で Prometheus テキスト形式(0.0.4)の全体メトリクスを出力します。プロセス、ポート転送、STUN、DDNS、証明書、Web サービスを対象とします。

スクレイプの設定 ​

  1. 「API トークン」ページで、「監視メトリクス」の読み取り権限(metrics:read)だけを持つトークンを作成します。このトークンでは他のエンドポイントにはアクセスできません。
  2. Prometheus の scrape_configs に次を追加します。
yaml
scrape_configs:
  - job_name: gately
    metrics_path: /api/metrics
    scheme: http
    authorization:
      credentials: gtl_xxxx
    static_configs:
      - targets: ["gately.example.lan:16680"]

メトリクス一覧 ​

メトリクス型説明
gately_build_info{version,commit,goversion}gaugeビルド情報。値は常に 1
gately_uptime_secondsgaugeプロセスの稼働時間
gately_goroutines / gately_memory_alloc_bytesgaugegoroutine 数とヒープメモリ
gately_cert_days_remaining{cert}gauge証明書の有効期限までの日数
gately_cert_expiry_timestamp_seconds{cert}gauge証明書の有効期限
gately_ddns_record_up{task,record,type}gauge直近の同期が成功したか(1 = 成功)
gately_ddns_last_update_timestamp_seconds{...}gaugeレコードが最後に変更された時刻
gately_stun_up{rule}gaugeSTUN ルールに有効なマッピングがあるか
gately_stun_connections_total{rule}counterSTUN の内蔵フォワーディングが処理した接続数
gately_portforward_active_connections{rule}gauge転送ルールの現在の接続数
gately_portforward_connections_total{rule}counter転送ルールが受け付けた接続数
gately_portforward_bytes_total{rule,direction}counter中継したバイト数(in はクライアントから転送先方向)
gately_site_requests_total{listener,site}counterサイトごとのリクエスト数
gately_site_responses_total{listener,site,class}counterステータスの種類(2xx/3xx/4xx/5xx)ごとのレスポンス数
gately_site_response_bytes_total / gately_site_errors_total / gately_site_active_requestscounter / counter / gaugeレスポンスのバイト数、バックエンドのエラー数、処理中のリクエスト数
gately_upstream_up{listener,site,upstream}gaugeバックエンドが正常か

アラートの例 ​

yaml
groups:
  - name: gately
    rules:
      - alert: GatelyCertExpiring
        expr: gately_cert_days_remaining < 14
        for: 1h
      - alert: GatelyDDNSFailing
        expr: gately_ddns_record_up == 0
        for: 15m
      - alert: GatelyUpstreamDown
        expr: gately_upstream_up == 0
        for: 2m

Grafana ダッシュボード ​

Grafana で Import を選び、deploy/grafana/gately-dashboard.json をアップロードして、Prometheus のデータソースを選択します。

Apache-2.0 ライセンスで公開されています。