buildServiceDiscoveryJson

Builds a Prometheus-compatible service discovery JSON response.

This method generates a JSON array in the format expected by Prometheus HTTP service discovery. Each registered path is represented as a target with associated labels that Prometheus can use for scraping configuration.

The generated JSON includes:

  • targets: Array containing the proxy endpoint for each path

  • labels: Metadata about each target including:

  • __metrics_path__: The path to scrape

  • agentName: Names of agents serving this path

  • hostName: Hostnames of agents serving this path

  • Custom labels from agent path configuration

Example Output

[
{
"targets": ["proxy.example.com:8080"],
"labels": {
"__metrics_path__": "/app1_metrics",
"agentName": "agent-01",
"hostName": "internal.host.com",
"environment": "production",
"service": "web"
}
}
]

Return

JsonArray containing service discovery information for all registered paths

See also