exposition
Prometheus text-based exposition parse and stringify
Usage
const parsed = Exposition;
API
parse(str)
Parse a Prometheus text-formatted exposition string and return as an object representation. For example, the following entry is parsed as the below object.
# HELP net_agg_packets_in Aggregate inbound packets
# TYPE net_agg_packets_in counter
net_agg_packets_in 153
Exposition will also parse more complex structures, for example:
# 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
is represented as
stringify(array)
Returns an exposition text-formatted representation of the array of objects.
Example:
const Exposition = ; const input = name: 'net_agg_packets_in' help: 'Aggregate inbound packets' type: 'COUNTER' metrics: value: '153' ; console;
result:
# HELP net_agg_packets_in Aggregate inbound packets
# TYPE net_agg_packets_in counter
net_agg_packets_in 153