Files
linearvoid/docs/infrastructure/monitoring/prometheus_curl_win.md
T

3.7 KiB
Raw Blame History

Prometheus scrape target metric names (Windows)

Below are cURL one‑liners you can run from a Windows command prompt (or PowerShell) that query the Prometheus HTTP API and print the raw JSON list of metric names for each target.
Since jq isn’t installed, the commands simply echo the JSON response; you can pipe it to findstr or PowerShell’s ConvertFrom‑Json if you want a prettier view.


1. Chat (http://chat:3000/metrics)

curl "http://localhost:9090/api/v1/label/__name__/values?match[]={job=\"chat\",instance=\"chat:3000\"}"

2. NGINX exporter (http://nginx-exporter:9113/metrics)

curl "http://localhost:9090/api/v1/label/__name__/values?match[]={job=\"nginx\",instance=\"nginx-exporter:9113\"}"

3. Node exporter (http://node-exporter:9100/metrics)

curl "http://localhost:9090/api/v1/label/__name__/values?match[]={job=\"node\",instance=\"node-exporter:9100\"}"

4. Playout (http://playout:8081/metrics)

curl "http://localhost:9090/api/v1/label/__name__/values?match[]={job=\"playout\",instance=\"playout:8081\"}"

5. Postgres exporter (http://postgres-exporter:9187/metrics)

curl "http://localhost:9090/api/v1/label/__name__/values?match[]={job=\"postgres\",instance=\"postgres-exporter:9187\"}"

6. Prometheus itself (http://prometheus:9090/metrics)

curl "http://localhost:9090/api/v1/label/__name__/values?match[]={job=\"prometheus\",instance=\"prometheus:9090\"}"

7. Redis exporter (http://redis-exporter:9121/metrics)

curl "http://localhost:9090/api/v1/label/__name__/values?match[]={job=\"redis\",instance=\"redis-exporter:9121\"}"

Making the output a bit more readable (optional)

If you have PowerShell (available on Windows 10/11), you can format the JSON nicely:

curl "http://localhost:9090/api/v1/label/__name__/values?match[]={job=`"chat`",instance=`"chat:3000`"}" |
  ConvertFrom-Json |
  Select-Object -ExpandProperty data |
  Sort-Object

Replace the URL part with the one for the target you’re interested in. The pipeline:

  1. Calls curl (the built‑in alias for Invoke-WebRequest in PowerShell).
  2. ConvertFrom-Json parses the JSON.
  3. Select-Object -ExpandProperty data extracts the array of metric names.
  4. Sort-Object alphabetizes them.

You can similarly pipe the output to findstr /i "http_requests_total" to search for a particular metric name without any extra tools.


Quick checklist

Item What to adjust
Prometheus address If your Prometheus container isn’t bound to localhost:9090, replace localhost:9090 with the appropriate host/port (e.g., 127.0.0.1:9090).
Target job/instance The job and instance values must match the labels shown in your UI (they’re case‑sensitive).
PowerShell vs CMD The raw curl commands work in both CMD and PowerShell; the PowerShell‑only pretty‑print uses ConvertFrom‑Json.

Run the command for any target and you’ll receive a JSON payload like:

{
  "status": "success",
  "data": [
    "up",
    "process_cpu_seconds_total",
    "http_requests_total",
    "... more metrics ..."
  ]
}

That array (data) is the complete list of metric names currently scraped from the specified endpoint.