Prometheus scrape (prometheus)
Fetches the text exposition of a Prometheus exporter (/metrics) and turns the series you select into channels. A selection names a metric and label matchers, like a Prometheus selector, and says what to do when several series match. A counter can be reported as a rate.
Channels
| Key | Name | Unit | Default limits |
|---|---|---|---|
scrape_ms | Scrape time | ms | warning above 5000 |
series_total | Series in the response | none | none |
one per entry of select | its name, or its key | its unit, or the one the metric name implies | none. Set limits on the sensor. |
Parameters
| Parameter | Default | Meaning |
|---|---|---|
scheme | http | http or https. |
port | 80 or 443 | TCP port. Exporters use their own: set it (9100 for node_exporter). |
path | /metrics | Request path and query. |
verify_tls | true | Check the server certificate. |
tls_fingerprint | none | Trust exactly the certificate with this SHA-256 fingerprint (colon-separated or plain hex, either case) and no other, whatever its chain, dates or name say; verify_tls is then not needed. See pinning a certificate. |
headers | none | Extra request headers. Not for credentials. |
auth | none | {"type": "bearer"} sends the secret credential as a bearer token. basic and header also work, see HTTP content. |
select | required | 1 to 50 selections, below. |
max_body_bytes | 4194304 | The most response body to read, 1024 to 16777216. A larger response fails the poll. |
A selection:
| Field | Default | Meaning |
|---|---|---|
key | required | The channel key: lower case letters, digits and _, at most 40 characters. History is stored under it, so do not change it. scrape_ms and series_total are reserved. |
metric | required | The metric name, for example node_load1. Histogram and summary lines are series of their own, for example request_duration_seconds_bucket with le. |
labels | none | Matchers: {"label": "mountpoint", "op": "eq", "value": "/"}. op is eq, ne, re or nre; the regular expressions are anchored, as in PromQL. At most 8. |
aggregate | single | What to do when several series match. single demands exactly one and makes the sensor Down otherwise, so a label that changes meaning is noticed. sum, min, max, avg and count combine them. |
rate | false | Report the increase per second since the previous scrape instead of the value. The first scrape, and a scrape after the counter went down (a reset), give an unknown value. |
scale | 1 | The value is multiplied by this, after the rate. |
required | true | A series that is missing makes the sensor Down. With false the channel is just unknown. |
name | the key | The name shown for the channel, up to 80 characters. |
unit | see below | The unit of the reported value, for example ms, B, %, s. |
Names and units
The template cannot know a selection's channel, so its name and unit come from the selection itself, before any poll: name (the key if it is missing) and unit. When unit is missing and scale is 1, Probeward uses the unit that Prometheus' naming conventions give the metric: _bytes is B (a rate of a _bytes or _bytes_total metric is B/s), _seconds is s, _celsius is °C and _percent is %. With a scale, a count aggregate or any other rate, nothing is implied and the channel has no unit unless you give one: you changed what the number means. seconds, milliseconds, bytes, percent and celsius are read as s, ms, B, % and °C, which the interface formats as times and sizes; any other unit is shown as written. Names and units are shown as plain text, and the key stays the channel's identity.
Suggested interval: 60 seconds. Credential: an optional secret, used when auth is set.
NaN and infinite values are unknown. Rates need the previous value, which is kept in the sensor's state; if you forget the state the next rate is unknown again.
Limits
The response may not be larger than max_body_bytes, and may not hold more than 100000 series. Both are failures, not partial reads: a half-read endpoint would give wrong numbers. For a big exporter, scrape a path that exposes less, or put a filtering proxy in front.
The classic text format and the text form of OpenMetrics (exemplars and timestamps are tolerated, # EOF is ignored) are read. The protobuf format is not. Metric names in quotes (the newer UTF-8 form) are not read.
Failures
| Message | Meaning |
|---|---|
no series matches <metric> | Down. The exporter works, the series is not there. |
N series match <metric>; narrow the label matchers or choose an aggregate | Down. |
the response holds no metrics (is this a Prometheus endpoint?) (kind protocol) | The body is not exposition text. |
the response is larger than N bytes / more than 100000 series (kind protocol) | A limit. |
the server answered HTTP 401 (kind auth_failed) | The token is wrong. |
Verification
It has not been run against every exporter; text that follows the format should work.