Hitachi

JP1 Version 13 JP1/Integrated Management 3 - Manager コマンド・定義ファイル・APIリファレンス


5.23 JP1/IM - Agentが使用するExporterのスクレイプ用のAPI

機能

Prometheus serverのスクレイプ対象の各Exporterのスクレイプを実行します。Prometheus設定ファイル(jpc_prometheus_server.yml)の項目「scrape_interval」に設定された間隔で,スクレイプを実行します。

ステータスコードに200以外が返却されてもリトライは行いません。

通信方式

通信プロトコル:HTTP

ポート番号:Exporterのポート番号

形式
リクエスト行
GET /metrics※ HTTP/1.1

通信プロトコルは「HTTP」だけです。Exporterのポート番号を指定します。

注※

「/metrics」の部分は,Prometheus設定ファイル(jpc_prometheus_server.yml)の<scrape_configs>の項目「metrics_path」で変更できます。

リクエストヘッダー

ヘッダー名

設定値

host

Prometheus設定ファイル(jpc_prometheus_server.yml)の項目「targets」の値が設定されます。

user-agent

「Prometheus/2.23.0」が設定されます。

accept

「application/openmetrics-text; version=0.0.1,text/plain;version=0.0.4;q=0.5,*/*;q=0.1」が設定されます。

accept-encoding

「gzip」が設定されます。

x-prometheus-scrape-timeout-seconds

Prometheus設定ファイル(jpc_prometheus_server.yml)の項目「scrape_timeout」の値が設定されます。

その他

Prometheus設定ファイル(jpc_prometheus_server.yml)の設定内容に合わせて,認証情報などが追加されます。

リクエストのメッセージボディー

なし

レスポンスのメッセージボディー

次に示すPrometheusのテキストフォーマットで情報を返却します。

■基本情報

項目

説明

サポート対象のPrometheusのバージョン

0.40以降

通信プロトコル

HTTP

エンコーディング

UTF-8

改行文字は「\n」を使用してください。

HTTPコンテンツのデータ形式(Content-Type)

text/plain; version=0.0.4

バージョンの値がない場合は,最新のテキストフォーマットのバージョンとして扱われます。

HTTPコンテンツのエンコーディング(オプション)-

gzip

サポート対象のメトリック

  • Counter

  • Gauge

  • Histogram

  • Summary

  • Untyped

■テキストフォーマットの詳細

  • 行単位で記述します。

  • 行の終端の改行文字は'\n'としてください。

  • 空行は無視されます。

■行のフォーマット

  • 1行に記述するトークンは,任意の数の空白またはタブで区切ることができます。

  • 先頭および末尾の空白は無視されます。

■コメント,ヘルプテキスト,型情報

  • 「#」で始まる行はコメント扱いとなります。「#」の直後のトークンが"HELP"または型情報でない行は無視されます。

  • 「#」の直後のトークンが"HELP"の場合は,少なくとも1つのメトリック名のトークンが必要です。残りのすべてのトークンはそのメトリック名に対する説明文とみなされます。

    ヘルプテキストの行は,メトリック名の後ろに任意のUTF-8の文字列を含めることができますが,バックスラッシュ(\)と改行文字(\n)については,「\\」と「\\n」のようにエスケープする必要があります。

    ヘルプテキストの行は,1つのメトリック名に対して1行だけ記述できます。

  • 「#」の直後のトークンが型情報の場合は,2つ以上のトークンを記述します。1つ目はメトリック名,2つ目はcounter,gauge,histogram,summary,またはuntypedのどれかで,メトリックの型を定義します。

    型情報の行は,1つのメトリック名に対して1行だけ記述できます。

    型情報の行は,その行のメトリック名に対する最初のサンプルの前に表示する必要があります。

    メトリック名に対する型情報の行が存在しない場合,そのメトリックの型には「untyped」が設定されます。

■サンプルの構文

metric_name [
    "{" label_name "=" `"` label_value `"` { "," label_name "=" `"` label_value `"` } [ "," ] "}"
] value [ timestamp ]
  • metric_nameとlabel_nameには,通常のPrometheusでの記述の制約があります。

  • label_valueは,任意のUTF-8文字列です。バックスラッシュ(\),ダブルクォート("),ラインフィードは,それぞれ「\\」,「\"」,「\\n」として,エスケープする必要があります。

  • valueは,GoのParseFloat()関数で必要とされる浮動小数点数付きの数値です。通常の数値以外に,NaN(数値ではない),+Inf(正の無限大),-Inf(負の無限大)の値も有効です。

  • タイムスタンプは,int64(1970-01-01 00:00:00 UTCからのミリ秒(うるう秒を除く))です。GoのParseInt()関数で必要に応じて表示されます。

■グルーピングとソート

  • 1つのメトリックに対するすべての行は,オプションのヘルプテキストの行と型情報の行と合わせて,1つのグループとして提供する必要があります。

  • 各行は,メトリック名とラベルのユニークな組み合わせになっている必要があります。

■テキストフォーマットの例

# HELP http_requests_total The total number of HTTP requests.
# TYPE http_requests_total counter
http_requests_total{method="post",code="200"} 1027 1395066363000
http_requests_total{method="post",code="400"}    3 1395066363000
 
# Escaping in label values:
msdos_file_access_time_seconds{path="C:\\DIR\\FILE.TXT",error="Cannot find file:\n\"FILE.TXT\""} 1.458255915e9
 
# Minimalistic line:
metric_without_timestamp_and_labels 12.47
 
# A weird metric from before the epoch:
something_weird{problem="division by zero"} +Inf -3982045
 
# A histogram, which has a pretty complex representation in the text format:
# HELP http_request_duration_seconds A histogram of the request duration.
# TYPE http_request_duration_seconds histogram
http_request_duration_seconds_bucket{le="0.05"} 24054
http_request_duration_seconds_bucket{le="0.1"} 33444
http_request_duration_seconds_bucket{le="0.2"} 100392
http_request_duration_seconds_bucket{le="0.5"} 129389
http_request_duration_seconds_bucket{le="1"} 133988
http_request_duration_seconds_bucket{le="+Inf"} 144320
http_request_duration_seconds_sum 53423
http_request_duration_seconds_count 144320
 
# Finally a summary, which has a complex representation, too:
# HELP rpc_duration_seconds A summary of the RPC duration in seconds.
# TYPE rpc_duration_seconds summary
rpc_duration_seconds{quantile="0.01"} 3102
rpc_duration_seconds{quantile="0.05"} 3272
rpc_duration_seconds{quantile="0.5"} 4773
rpc_duration_seconds{quantile="0.9"} 9001
rpc_duration_seconds{quantile="0.99"} 76656
rpc_duration_seconds_sum 1.7560473e+07
rpc_duration_seconds_count 2693