Prometheus 형식

Prometheus 형식

Prometheus 형식은 Prometheus 텍스트 기반 exposition 형식으로 메트릭을 노출해요. 출력 테이블은 name, value 컬럼을 반드시 가져야 하며, help, timestamp, type, labels 컬럼을 선택적으로 가질 수 있어요.

출처: 문서

본문

Input Output Alias

설명 (Description)

Prometheus 텍스트 기반 exposition 형식으로 메트릭을 노출합니다. 이 형식의 경우 출력 테이블이 다음 규칙에 따라 올바르게 구조화되어야 합니다:

  • name (String)과 value(숫자) 컬럼이 필요합니다.
  • 행에는 선택적으로 help (String)과 timestamp(숫자)가 포함될 수 있어요.
  • type (String) 컬럼은 counter, gauge, histogram, summary, untyped 중 하나이거나 비어 있어야 합니다.
  • 각 메트릭 값은 선택적으로 몇 개의 labels (Map(String, String))를 가질 수 있어요.
  • 연속된 여러 행이 서로 다른 labels로 하나의 메트릭을 참조할 수 있습니다. 테이블은 메트릭 이름으로 정렬되어야 합니다(예: ORDER BY name).

histogram과 summary 레이블에는 특별한 요구사항이 있습니다. 자세한 내용은 Prometheus 문서를 참조하세요.

{'count':''}{'sum':''} 레이블이 있는 행에는 특별 규칙이 적용되며, 각각 <metric_name>_count<metric_name>_sum으로 변환됩니다.

사용 예시 (Example usage)

┌─name────────────────────────────────┬─type──────┬─help──────────────────────────────────────┬─labels─────────────────────────┬────value─┬─────timestamp─┐
│ http_request_duration_seconds       │ histogram │ A histogram of the request duration.      │ {'le':'0.05'}                  │    24054 │             0 │
│ http_request_duration_seconds       │ histogram │                                           │ {'le':'0.1'}                   │    33444 │             0 │
│ http_request_duration_seconds       │ histogram │                                           │ {'le':'0.2'}                   │   100392 │             0 │
│ http_request_duration_seconds       │ histogram │                                           │ {'le':'0.5'}                   │   129389 │             0 │
│ http_request_duration_seconds       │ histogram │                                           │ {'le':'1'}                     │   133988 │             0 │
│ http_request_duration_seconds       │ histogram │                                           │ {'le':'+Inf'}                  │   144320 │             0 │
│ http_request_duration_seconds       │ histogram │                                           │ {'sum':''}                     │    53423 │             0 │
│ http_requests_total                 │ counter   │ Total number of HTTP requests             │ {'method':'post','code':'200'} │     1027 │ 1395066363000 │
│ http_requests_total                 │ counter   │                                           │ {'method':'post','code':'400'} │        3 │ 1395066363000 │
│ metric_without_timestamp_and_labels │           │                                           │ {}                             │    12.47 │             0 │
│ rpc_duration_seconds                │ summary   │ A summary of the RPC duration in seconds. │ {'quantile':'0.01'}            │     3102 │             0 │
│ rpc_duration_seconds                │ summary   │                                           │ {'quantile':'0.05'}            │     3272 │             0 │
│ rpc_duration_seconds                │ summary   │                                           │ {'quantile':'0.5'}             │     4773 │             0 │
│ rpc_duration_seconds                │ summary   │                                           │ {'quantile':'0.9'}             │     9001 │             0 │
│ rpc_duration_seconds                │ summary   │                                           │ {'quantile':'0.99'}            │    76656 │             0 │
│ rpc_duration_seconds                │ summary   │                                           │ {'count':''}                   │     2693 │             0 │
│ rpc_duration_seconds                │ summary   │                                           │ {'sum':''}                     │ 17560473 │             0 │
│ something_weird                     │           │                                           │ {'problem':'division by zero'} │      inf │      -3982045 │
└─────────────────────────────────────┴───────────┴───────────────────────────────────────────┴────────────────────────────────┴──────────┴───────────────┘

다음과 같이 형식화됩니다:

# 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.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

# HELP http_requests_total Total number of HTTP requests
# TYPE http_requests_total counter
http_requests_total{code="200",method="post"} 1027 1395066363000
http_requests_total{code="400",method="post"} 3 1395066363000

metric_without_timestamp_and_labels 12.47

# 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 17560473
rpc_duration_seconds_count 2693

something_weird{problem="division by zero"} +Inf -3982045

형식 설정 (Format settings)

더 알아보기 (Learn more)