跳到主要内容

Metric and label naming

Metric names

  • should have a (single-word) application prefix relevant to the domain the metric belongs to. The prefix is sometimes referred to as namespace by client libraries
    • prometheus_notifications_total (specific to the Prometheus server)
    • process_cpu_seconds_total (exported by many client libraries)
    • http_request_duration_seconds (for all HTTP requests)
  • must have a single unit (i.e. do not mix seconds with milliseconds, or seconds with bytes)
  • should use base units (e.g. seconds, bytes, meters - not milliseconds, megabytes, kilometers)
  • should have a suffix describing the unit, in plural form. Note that an accumulating count has total as a suffix, in addition to the unit if applicable
    • http_request_duration_seconds
    • node_memory_usage_bytes
    • http_requests_total (for a unit-less accumulating count)
    • process_cpu_seconds_total (for an accumulating count with unit)
    • foobar_build_info (for a pseudo-metric that provides metadata about the running binary)
    • data_pipeline_last_record_processed_timestamp_seconds (for a timestamp that tracks the time of the latest record processed in a data processing pipeline)

As a rule of thumb, either the sum() or the avg() over all dimensions of a given metric should be meaningful (though not necessarily useful). If it is not meaningful, split the data up into multiple metrics

Base units

  • Time seconds
  • Bytes bytes
  • Percent ratio Values are 0–1 (rather than 0–100). ratio is only used as a suffix for names like disk_usage_ratio. The usual metric name follows the pattern A_per_B