South Star

Prometheus Text Parser Labels NaN Inf HELP TYPE API

Free tier included · Monitoring
Parse Prometheus /metrics text to JSON: labels, NaN/Inf, timestamps, HELP/TYPE.

Every service that exposes a `/metrics` endpoint speaks Prometheus text exposition format 0.0.4, and every tool that consumes it has to re-implement the same fiddly parsing rules: quoted label values with `\\`, `\"` and `\n` escapes, values like `+Inf`, `-Inf`, `NaN` and `1.5e+09`, optional millisecond timestamps, and `# HELP` / `# TYPE` directives that must be attributed to the right family (including `_bucket`, `_sum`, `_count` and `_total` suffixes). Get one of those wrong and a whole scrape silently disappears.

This API does it in one POST. Send the raw text, get back a `metrics` array with `name`, `labels`, `value`, `timestamp`, `type` and `help`, plus an `invalid_lines` list with line numbers and reasons — one broken line never kills the rest of the payload. Pass `?strict=true` when you'd rather have the first bad line reject the request with a 422.

Who uses it: observability pipelines validating scraped text before ingestion; SRE tooling auditing which metric families and types a fleet actually exposes (via `POST /summarize`); dashboards and notebooks that need `/metrics` output as JSON; CI checks that fail a build when an exporter starts emitting malformed lines.

Why this one: it is stdlib-only and offline — no external calls, no storage, no per-request state — and the parser is checked against `prometheus_client` on node_exporter's end-to-end fixtures and Prometheus `textparse` testdata, including the Prometheus 3 UTF-8 form (`{"my.metric", "label.with.dots"="v"} 1` and quoted names in directives). It is fast: parsing is regex plus arithmetic on short strings.

Endpoints

MethodPathWhat it does
POST/parseParse one Prometheus text payload into structured metrics; malformed lines are reported in invalid_lines (or rejected with 422 in strict mode via ?strict=true).
POST/summarizeReturn family-level counts for a payload — unique series, samples, a histogram by declared metric type, and how many lines were invalid — without the full sample list.

Quick start

curl -X POST "https://promtext.p.rapidapi.com/parse" \
  -H "X-RapidAPI-Key: YOUR_RAPIDAPI_KEY" \
  -H "X-RapidAPI-Host: promtext.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{"text":"# HELP http_requests_total Total number of HTTP requests.\n# TYPE http_requests_total counter\nhttp_requests_total{method=\"post\",code=\"200\"} 1027 1395066363000\nhttp_requests_total{method=\"post\",code=\"400\"} 3\n"}'

FAQ

What happens when a payload contains malformed lines?

By default they are skipped and listed in `invalid_lines` with `line`, `line_no` and `reason`; every valid line is still parsed. Add `?strict=true` to `POST /parse` and the first invalid line returns HTTP 422 with its position instead.

Is my metric text stored or sent anywhere?

No. Parsing is offline and stateless — the body is parsed in memory and returned, with no database, no request logs and no external calls.

Does it handle weird exporters, escapes and Infinity/NaN?

Yes: quoted label values with `\\`, `\"` and `\n` escapes, blanks between the name and `{`, `+Inf`/`-Inf`/`Inf`/`NaN`, scientific notation, optional millisecond timestamps, HELP text unescaping, and the Prometheus 3 UTF-8 quoted-name form. NaN and ±Inf are emitted as JSON `NaN` / `Infinity` literals, which Python's `json.loads` reads natively.

How large a payload and how many metrics can I send?

One payload per request, up to 5,242,880 bytes of text, with as many metric lines as fit in it. For bulk auditing across many targets, call `/summarize` per scrape — it returns counts only, so responses stay small.

Try Prometheus Text Parser Labels NaN Inf HELP TYPE free

Free tier on every plan. Get an API key and start calling in under a minute.

Open on RapidAPI

Related APIs