Reading values from a text answer
A partner that answers in text, not JSON, reaches your flow as one string. A field access on that
string fails the step. The extract fence turns the text into an object whose fields are the values
you named, so the next step reads them like any other field.
The one format today is prometheus: the text a /metrics route answers.
A flow that reads two indicators
## Step: scrapeeffects: [http_egress]endpoint: https://nui.example.test/metricsmethod: GET
## Step: pick```extractformat: prometheusnui_service_mode_stateunprocessed_requests_from_offline_buffer_nui```
## Step: shape```ntd{ "mode": {{ $.nui_service_mode_state }} }```The extract step reads the message the step before it left, which must be the page as text. It
replaces the message with an object keyed by the selectors, in the order you wrote them:
{ "nui_service_mode_state": 1, "unprocessed_requests_from_offline_buffer_nui": 17 }The fence
The first line is format: prometheus. Every other line is one selector. Blank lines are ignored.
| Selector | Picks |
|---|---|
name |
The series called name |
name{label="value"} |
The series called name that carries the label with that value |
name{a="1",b="2"} |
The series that carries both labels |
A selector is exact: equality only, no pattern. A label value may hold the escapes \\, \" and
\n. The key in the output is the selector exactly as you wrote it.
A selector must pick exactly one series. A page with no series for it, or with two or more, is a fault: the step does not return an object that holds only some of the values you asked for.
What the page may hold
The reader takes the text exposition format, version 0.0.4:
- Blank lines and
#comment lines, including# HELP,# TYPEand# EOF, are skipped. - A sample is
name, an optional{label="value",...}list (a trailing comma is allowed), a value, and an optional timestamp. Lines end with\nor\r\n. - A value is a finite decimal number:
1,-2.5,1e3,.5,+7. A whole number that fits stays a whole number.NaN,+Inf,-Infand hexadecimal are refused. - An exemplar (a
#after a sample) and any other text after the sample are refused.
When it fails
Each of these stops the flow at the extract step and runs the flow’s ## Fault: section, if it
has one (see Faults):
- The message is not text, for example a JSON answer. The fault names its type.
- A line is outside the format. The fault names the line number and a short reason, never the line’s text.
- A selector picks no series, or more than one. The fault names the selector, and the count when there is more than one.
- The page or a line is over a limit.
Because the fault carries no text from the page, it is safe to return to the caller or write to a log.
Limits
| Limit | Value |
|---|---|
| Selectors in one fence | 64 |
| One selector line | 256 bytes |
| The page | 4 MiB |
| One line of the page, line end not counted | 8 KiB |
A fence over the first two is refused when you publish the flow. The page and line limits apply at run time. The same figures are in Limits and constraints.