Caddy.Metrics.Parser (Caddy v2.3.1)
View SourcePrometheus text format parser.
Parses Prometheus exposition format into %Caddy.Metrics{} structs.
Prometheus Format
The Prometheus text format consists of:
- Comments starting with
# - HELP lines:
# HELP metric_name description - TYPE lines:
# TYPE metric_name type - Metric lines:
metric_name{label="value"} number timestamp?
Supported Metric Types
counter- Monotonically increasing valuegauge- Value that can go up or downhistogram- Buckets + sum + countsummary- Quantiles + sum + count
Summary
Functions
Parse Prometheus text format into a Metrics struct.
Functions
@spec parse(binary()) :: Caddy.Metrics.t()
Parse Prometheus text format into a Metrics struct.
Examples
text = """
# HELP caddy_http_requests_total Total HTTP requests
# TYPE caddy_http_requests_total counter
caddy_http_requests_total{server="srv0",code="200"} 1234
"""
metrics = Caddy.Metrics.Parser.parse(text)
metrics.http_requests_total
#=> %{%{server: "srv0", code: "200"} => 1234}