Status: Experimental (Work in Progress)
Official Rust libraries for Prometheus and OpenMetrics metric collection pipelines: wire exposition format decoding (prometheus-expfmt), target and metric relabeling (prometheus-relabel), and service discovery and scrape management (prometheus-scrape-manager).
scrape.rs provides the building blocks required to discover targets, relabel labels, scrape HTTP endpoints, and decode Prometheus and OpenMetrics payloads in Rust:
Service discoveries
-> Target relabeling
-> Scrape manager / HTTP fetch
-> Streaming expfmt parser
-> Stage 1: family `__name__` filter pushdown
-> Metric family assembly & string interning
-> Stage 2: dictionary-vectorized relabeling & `honor_labels`
-> Columnar Apache Arrow (OTAP) batches or Protobuf DTOs
The project serves two main use cases:
- Columnar scraping for OpenTelemetry Arrow.
open-telemetry/otel-arrow#3277defines an OTAP-nativeprometheus_scrapereceiver in Rust.scrape.rsstreams scrape bytes through early__name__family filtering, metric family assembly, and dictionary-vectorized relabeling directly into Apache Arrow (OtapArrowRecords) tables on thread-per-core!Sendruntimes with bounded memory. - Standalone Rust Prometheus tooling. Validation harnesses such as OpenTelemetry Weaver live-checking
/metricsendpoints against semantic conventions, CLIs, and custom collectors can depend on individual pure-CPU crates (prometheus-expfmtorprometheus-relabel) without pulling in async HTTP or service discovery dependencies.
| Crate | Path | Status | Specification | Scope |
|---|---|---|---|---|
prometheus-expfmt |
crates/expfmt |
In progress | specs/SPEC.md | Content-Type and Accept negotiation, zero-copy streaming parsers for Prometheus Text 0.0.4, OpenMetrics 1.0, OpenMetrics 2.0, and Prometheus Protobuf, primary Apache Arrow / OTAP decoder (ArrowDecoder), and MetricFamily protobuf DTO decoder. |
prometheus-relabel |
crates/relabel |
In progress | specs/SPEC.md | Prometheus-compatible target and metric relabeling (replace, keep, drop, hashmod, labelmap, labeldrop, labelkeep, lowercase, uppercase, keepequal, dropequal), Stage 1 __name__ filter pushdown, and Stage 2 dictionary-vectorized relabeling and honor_labels resolution. |
prometheus-scrape-manager |
crates/scrape-manager |
In progress | specs/SPEC.md | Bounded concurrent and sequential target scrape scheduling (scrape), Prometheus HTTP/TLS client configuration (http_config), and service discovery mechanisms (discovery: static, file, HTTP, DNS, Kubernetes). |
Install mise 2026.11.14 or newer, the version CI pins and mise.toml requires, then run from the repository root:
mise trust
mise install
mise run build
mise run testrust-toolchain.toml pins the compiler and components for both rustup and mise; Cargo.toml records the minimum supported Rust version, which CI checks separately. mise.lock locks tool downloads. After changing a tool version, run mise lock explicitly and commit the updated lockfile.
The tasks in mise.toml compile through mbx, which caches compiler outputs across checkouts. Plain Cargo remains supported, but does not use mbx's shared cache.
Use mise tasks to list tasks. mise run lint, mise run lint-no-default, mise run test-no-default, and mise run fmt-check run the corresponding CI checks, and mise run ci runs all of them in CI order; mise run fmt formats in place. Extra arguments are forwarded to Cargo, and mise consumes the first --, so test-binary flags need two separators:
mise run test -p prometheus-expfmt
mise run test -p prometheus-expfmt -- -- --nocaptureRun the workspace unit and fixture test suite:
mise run testRun the otel-arrow-dfe-pdata compatibility test suite, a separate workspace with its own manifest:
mise run otap-testRun the Go differential fixture extractor and tests (requires Go):
cd tests/go-harness && go test ./...Run the decoding, relabeling, and scrape scheduling benchmarks in Go benchfmt format for benchstat:
mise run bench -p prometheus-expfmt --bench decode -- -- -bench '^BenchmarkDecode' -benchtime 1s -count 6 -cpu 2 -benchmem | tee decode.txt
mise run bench -p prometheus-relabel --bench relabel -- -- -bench '^BenchmarkRelabel' -benchtime 1s -count 6 -cpu 2 -benchmem | tee relabel.txt
mise run bench -p prometheus-scrape-manager --bench scrape -- -- -bench '^BenchmarkScrape' -benchtime 500ms -count 6 -cpu 2 -benchmem | tee scrape.txt