Skip to content

[DEMO] cmd/prometheus: OpenMetrics 1.0 vs 2.0 scrape demo on GCE - #7

Open
bwplotka wants to merge 5 commits into
mainfrom
demo-om2-scrape
Open

bwplotka wants to merge 5 commits into
mainfrom
demo-om2-scrape

Conversation

@bwplotka

@bwplotka bwplotka commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Live: https://35-204-166-191.sslip.io/

Runs Prometheus from main with --enable-feature=openmetrics2,exemplar-storage on a single small GCE VM. It scrapes a Go example (client_golang main) and a Java example (client_java main) twice each: once with scrape_protocols: [OpenMetricsText1.0.0] and once with [OpenMetricsText2.0.0]. The landing page links views that diff the series stored by the OM1 and OM2 jobs, and compare their values and exemplars.

The /metrics endpoints of both examples are public. /<go|java>/om1/metrics and /<go|java>/om2/metrics set the Accept header and serve the result as text/plain so browsers show it. /<go|java>/metrics passes the client's Accept header through.

Files in cmd/prometheus/demo_om2_gce/:

  • prometheus.yml: the 4 scrape jobs (go-om1, go-om2, java-om1, java-om2).
  • goapp/: the client_golang example. It's a separate module; deploy.sh bumps client_golang to GO_CLIENT_REF (main) at build time.
  • javaapp/: the client_java example and a Dockerfile that builds client_java from JAVA_CLIENT_REF (main) plus the example's fat jar, so neither the Cloudtop nor the VM needs a JDK.
  • landing.py: the landing page and the demo query links.
  • deploy.sh and startup.sh: based on the histogram compat demo ([DEMO] Histogram Query Conversions #4). Caddy serves TLS for <ip>.sslip.io, and the VM pulls releases from a private bucket. Prometheus runs as prom-demo@demo, and the examples run as prom-demo-app@{go,java}.

What the views show on current mains:

  • With OM2 scrapes, UTF-8 names are escaped (http.server.active_requests is stored as http_server_active_requests), because Prometheus doesn't send escaping=allow-utf-8 for OM2. The fix is in scrape: request escaping scheme for OpenMetrics 2.0 scrapes prometheus/prometheus#19902.
  • client_java's OM2 writer doesn't append _total or unit suffixes, so http_requests (OM2) and http_requests_total (OM1) are different series.
  • OM1 histogram exemplars are stored on _bucket series, OM2 ones on _count.
  • Histograms and summaries (composite values in OM2) are stored as the same classic series in both cases.

Usage:

CLOUDSDK_ACTIVE_CONFIG_NAME=prometheus-io PROJECT=macro-mile-203600 cmd/prometheus/demo_om2_gce/deploy.sh up|status|logs|ssh|down|build

Not meant to be merged.

krajorama and others added 4 commits October 2, 2026 10:34
The OpenMetrics 2.0 specification requires the fields of a histogram
composite value to appear in a fixed order: count, sum, schema,
zero_threshold, zero_count, negative_spans, negative_buckets,
positive_spans, positive_buckets and finally bucket. Some test inputs
listed the negative spans after the positive ones, or the classic
buckets before the native fields. The parser does not currently
enforce the order, so the tests passed regardless.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
…e-field-order

test(textparse): follow OM 2.0 composite field order in test inputs
Runs Prometheus from main with --enable-feature=openmetrics2 on a single GCE
VM, scraping a Go (client_golang main) and a Java (client_java main) example
twice each, with OpenMetrics 1.0 and with OpenMetrics 2.0, so the stored
series can be compared. The landing page links views that diff the series of
the OM1 and OM2 jobs and compare their values and exemplars. The example
/metrics endpoints are public, with /<app>/om1/metrics and /<app>/om2/metrics
setting the Accept header.

Based on the histogram compat demo deploy scripts. Not meant to be merged.

Signed-off-by: Bartek Plotka <bwplotka@google.com>
…Go app

Signed-off-by: Bartek Plotka <bwplotka@google.com>
# docker build --build-arg CLIENT_JAVA_REF=<sha> --output type=local,dest=<dir> .
#
# which writes <dir>/app.jar (a fat jar) and <dir>/client_java.version.
FROM eclipse-temurin:25-jdk AS build
…g page

Signed-off-by: Bartek Plotka <bwplotka@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants