Path: blob/main/docs/sources/flow/reference/stdlib/discovery_target_decode.md
5302 views
------discovery_target_decode
The discovery_target_decode function decodes a string into an array of targets matching the exports of discovery.* components.
The string must match the JSON format used by Prometheus' HTTP and file service discovery:
If the provided string doesn't match the expected JSON format, discovery_target_decode fails to evaluate and marks the component containing the expression as unhealthy.
Elements specified by the targets key are converted into a flat list of targets. The base set of labels for each target is retrieved from the labels key, and the __address__ label is received from the target element.
For example, the following JSON file maps to the River objects provided below:
Example pipeline
[local.file]: {{< relref "../components/local.file.md" >}}