Skip to content
@jennifer/prometheus

prometheus cheatsheet

Every export of @jennifer/prometheus. The guide is the introduction.

jennifer
import "@jennifer/prometheus/" as prometheus;

Functions

FunctionReturnsDoes
prometheus.counter(name as string, help as string)MetricBuild an empty counter metric
prometheus.gauge(name as string, help as string)MetricBuild an empty gauge metric
prometheus.histogram(name as string, help as string, buckets as list of float)MetricBuild an empty histogram metric
prometheus.summary(name as string, help as string, quantiles as list of float)MetricBuild an empty summary metric
prometheus.observe(metric as Metric, labels as map of string to string, value as float)MetricRecord an observation for a label set, returning a new Metric (value-semantic)
prometheus.observeAt(metric as Metric, labels as map of string to string, value as float, timestampMs as int)MetricRecord an observation carrying an explicit millisecond timestamp, returning a new Metric (value-semantic)
prometheus.render(metrics as list of Metric)stringRender a list of metrics as the Prometheus text exposition format
prometheus.pushgatewayPath(job as string, grouping as map of string to string)stringBuild the Pushgateway URL path for a job and a set of grouping labels
prometheus.query(base as string, promql as string)ResultRun an instant query against base (a Prometheus server URL) via /api/v1/query, returning the parsed result set
prometheus.queryRange(base as string, promql as string, start as string, end as string, step as string)ResultRun a range query against base via /api/v1/query_range, returning the parsed result matrix

Types

Sample

One recorded series of a metric, keyed by its label set.

FieldMeaning
labels as map of string to stringthe label name/value pairs ({} for none)
value as floatthe sample value (Counter / Gauge)
count as floatthe observation count (Histogram / Summary)
sum as floatthe observation sum (Histogram / Summary)
buckets as list of floatcumulative per-bucket counts (Histogram; parallel to Metric.buckets)
observations as list of floatthe raw observed values (Summary; source for quantiles)
timestamp as intan explicit millisecond timestamp, appended after the value when set
hasTimestamp as boolwhether timestamp is present and should be rendered

Metric

A metric family.

FieldMeaning
name as stringthe metric name ([a-zA-Z_:][a-zA-Z0-9_:]*)
help as stringthe HELP text (empty to omit the HELP line)
type as MetricTypethe metric type
samples as list of Samplethe recorded series
buckets as list of floatthe histogram upper bounds (le), ascending; empty for other types
quantiles as list of floatthe summary quantiles in [0, 1], ascending; empty for other types

Point

One (timestamp, value) point of a query result series.

FieldMeaning
timestamp as floatthe sample time as a Unix timestamp (seconds)
value as floatthe sample value

Series

One result series.

FieldMeaning
metric as map of string to stringthe series label set
values as list of Pointthe series points

Result

A parsed query result set.

FieldMeaning
resultType as string"vector", "matrix", "scalar", or "string" (a string result whose text is not a number throws)
series as list of Seriesthe result series

MetricType

A Prometheus metric type.

VariantMeaning
Counter
Gauge
Histogram
Summary