REST (JSON) (rest_json)
Requests a JSON document and reads the values you point at into channels. Text states can be mapped to numbers, and a value can be required to equal an expected one. Use it for status endpoints of appliances and services that have no sensor of their own.
Channels
| Key | Name | Unit | Default limits |
|---|---|---|---|
response_ms | Response time | ms | warning above 5000 |
one per entry of channels | its name, or its key | its unit, or none | none. Set limits on the sensor. |
Parameters
| Parameter | Default | Meaning |
|---|---|---|
scheme | https | http or https. |
port | 80 or 443 | TCP port. |
path | required | Request path and query, starting with /. |
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 | bearer, basic or header, with the secret credential, see HTTP content. |
max_body_bytes | 1048576 | The most response body to read, 1024 to 8388608. A larger response fails the poll. |
channels | required | 1 to 50 entries, below. |
A channel:
| Field | Default | Meaning |
|---|---|---|
key | required | Lower case letters, digits and _, at most 40 characters. response_ms is reserved. History is stored under it. |
path | required | Where the value is. A JSON Pointer starting with / (/status/cpu/0, with ~1 for a slash and ~0 for a tilde in a name), or a simple path (status.cpu[0]). Use a pointer for names that contain dots. |
scale | 1 | A numeric value is multiplied by this. |
value_map | none | {"from": "running", "to": 1} entries turn strings, numbers or booleans into numbers. Checked before numeric conversion. A text or boolean from is also the label shown for the whole number it maps to (running for 1) in the sensor page, the tree, incident pages and notifications; the stored number does not change. |
expected | none | The raw value must equal this (a string, a number or a boolean; "5" equals 5). Anything else makes the sensor Down. |
required | true | A missing value makes the sensor Down. |
name | the key | The name shown for the channel, up to 80 characters, as plain text. |
unit | none | The unit of the reported value (after scale), for example ms, B, %, s, °C. seconds, milliseconds, bytes, percent and celsius are read as those, which the interface formats as times and sizes; any other unit is shown as written. |
The template cannot know a document's values, so the name and unit of a channel come from its entry here, before any poll. The key stays the channel's identity: renaming a channel or changing its unit never touches the history.
Numbers, numeric strings and booleans (1 and 0) become numbers. A value that is none of these and has no map entry makes the sensor Down, naming the path, because a quiet "unknown" would hide the problem. Give a text state an expected value, or map it.
Suggested interval: 60 seconds. Credential: an optional secret, used when auth is set.
Failures
| Message | Meaning |
|---|---|
<path> not found in the response | Down. |
<path> is "x" but "y" was expected | Down. |
<path> is "x", which is not a number; add a value map entry for it | Down. |
the response is not valid JSON (kind protocol), the endpoint answered HTTP N (kind protocol) | The endpoint is not what you think it is. |
the server answered HTTP 401 (kind auth_failed) | The credential is wrong. |