About
This page is about metrics in Prometheus.
Example
Base
api_http_requests_total{method="POST", handler="/messages"}
where:
- the metric name is api_http_requests_total
- the labels are:
- method=“POST”
- handler=“/messages”
Metrics from the Prometheus server itself
prometheus_http_requests_total{code="200",handler="/"} 0
prometheus_http_requests_total{code="200",handler="/-/healthy"} 0
prometheus_http_requests_total{code="200",handler="/-/quit"} 0
prometheus_http_requests_total{code="200",handler="/-/ready"} 0
prometheus_http_requests_total{code="200",handler="/-/reload"} 0
prometheus_http_requests_total{code="200",handler="/alerts"} 0
prometheus_http_requests_total{code="200",handler="/api/v1/*path"} 0
prometheus_http_requests_total{code="200",handler="/api/v1/admin/tsdb/clean_tombstones"} 0
prometheus_http_requests_total{code="200",handler="/api/v1/admin/tsdb/delete_series"} 0
prometheus_http_requests_total{code="200",handler="/api/v1/admin/tsdb/snapshot"} 0
prometheus_http_requests_total{code="200",handler="/api/v1/alertmanagers"} 0
Syntax
A metric identifier is composed uniquely of:
- a name
- and one or more labels.
<metric name>{<label name>=<label value>, ...}
This is the same notation that OpenTSDB uses.
The metrics identifier is also known as time serie because when they are read/scraped, they create a time series with the following values:
- metric identifier
- time
- value
Name
The metric name specifies the general feature of a system that is measured.
Example for the total number of HTTP requests received:
http_requests_total
The name may contain:
- digits,
- underscores,
- and colons.
It must match the regex: [a-zA-Z_:][a-zA-Z0-9_:]*.
It must comply to the convention. For example:
- an accumulating count has total as a suffix
Management
Conf
See Prometheus - Collector to configure when the metrics are collected.
Location
By default, the metrics are made available at a URL endpoint known as a target with /metrics as path
Example:
- http://localhost:9090/metrics for the metrics of Prometheus with the default conf.
Example of metrics for the prometheus server.
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 0
go_gc_duration_seconds{quantile="0.25"} 0
go_gc_duration_seconds{quantile="0.5"} 0
go_gc_duration_seconds{quantile="0.75"} 0
go_gc_duration_seconds{quantile="1"} 0.0010366
go_gc_duration_seconds_sum 0.0020374
go_gc_duration_seconds_count 15
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 41
.......
Built-in attributes: Job / instance
When Prometheus scrapes a target, it attaches some labels automatically to the scraped time series which serve to identify the scraped target:
- job: The configured job name that the target belongs to.
- instance: The <host>:<port> part of the target's URL that was scraped.
More … Doc
How to get all metrics in the Prometheus server?
With the API
http://localhost:9090/api/v1/label/__name__/values