Skip to content

Fixes 38509: Correct Prometheus scrape metrics - #38938

Open
Vamsi-klu wants to merge 4 commits into
open-metadata:mainfrom
Vamsi-klu:codex/38509-prometheus-metrics
Open

Vamsi-klu wants to merge 4 commits into
open-metadata:mainfrom
Vamsi-klu:codex/38509-prometheus-metrics

Conversation

@Vamsi-klu

@Vamsi-klu Vamsi-klu commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes

Fixes #38509

Correct Jetty thread utilization to use configured capacity. Expose conventional Prometheus counter types, units, and route labels. The migration guide shows how to query old and new servers during a rollout.

Type of change

  • Bug fix

High-level design

  • A shared, bounded busy/max calculation supplies the ratio, legacy percentage, and diagnostics percentage. Search shard capacity uses the existing cached snapshot.
  • Canonical HTTP totals use separate counter families. Unsigned conversion handles Jetty's int-backed totals across the signed boundary. Request duration gauges and the process CPU alias use seconds.
  • The Prometheus registry exports the classified route as http_route alongside the HTTP method. Internal diagnostics continue to read the route from the composite registry. The latency CLI accepts both scrape formats and reports methods separately.
  • Legacy families support a mixed-version rollout. Canonical queue seconds depend on verified queue-wait instrumentation from [Metrics] Several metrics on /prometheus stay at 0 or NaN under real traffic (auth, search, entity, pipeline, db, jetty, S3 log storage) #38503.

Tests

Use cases covered

Allocated versus configured thread capacity, saturation, invalid capacity, separate HTTP status and Jetty failure counts, signed wrap, handler restart, time conversion, CPU availability, shard capacity, and route/method grouping.

Unit tests

  • The baseline Jetty test reproduced 76.92% with 10 busy, 13 allocated, and 50 maximum threads. The corrected value is 20%.
  • All 17 tests in the four changed metrics suites passed in the isolated JUnit run. The embedded Jetty server handled a 200 response, a 503 response, and a handler exception.
  • Isolated JaCoCo line coverage was 100% for SearchIndexMetrics, 97.1% for MicrometerBundle, 76.8% for JettyMetricsIntegration, and 65.0% for JettyMetrics. The direct diagnostics probe measured 82.4% line coverage for DiagnosticsResource. The new live admin scrape and GET/POST diagnostics case passed.
  • Spotless and impact-map ownership checks passed. The Maven unit step passed 34 of 35 tests. Its sole failure was the unchanged request latency timing test. It reproduced on untouched upstream and passed the targeted 1-test retry.

Backend integration tests

Local Java test run: FAILED

  • Commit: 7513ddc18bab (base origin/main)
  • Finished: 2026-11-27 08:58 UTC · 59.2 min
  • Focused scope. Nine broader steps are deferred.
Step Scope Classes Tests Failed Skipped Min Result
unit openmetadata-service (5 classes) 5 35 1 0 11.7 FAILED
integration mysql-elasticsearch · parallel 1 4 0 1 47.5 passed

Failed: RequestLatencyContextTest#testTimingAccuracyWithKnownDurations

  • Impacted, not run locally: 15 classes (listed in the details)

Ingestion integration tests

N/A for the Java monitoring changes.

Playwright (UI) tests

N/A for the admin scrape and CLI changes.

Manual testing performed

Ran Bash syntax validation. The latency CLI listed and analyzed the exact table route for separate GET and POST samples with http_route, legacy endpoint, and legacy exported_endpoint. The isolated Prometheus registry confirmed exact sample names, types, conversion, and compatibility. Promtool v3.8.0 passed the 12 new canonical families exported by the candidate registry. All six migration PromQL expressions and the mixed-version rule fixtures passed.

UI screen recording

N/A for the admin scrape and CLI changes.

Checklist

  • Read CONTRIBUTING.md and the contributor guide.
  • Used the issue-linked title and description.
  • Added a regression for the original denominator and coverage for the canonical scrape.
  • Reviewed commit 7513ddc18bab4dd3c35e5cb682f5ef05072abda8 against REVIEW.md.
  • Added the operator migration guide and decision record.
  • Recorded focused Java results and the passing timing-test retry.
  • Verify the mixed-version staging scrape with promtool and the deployment's ServiceMonitor and alert rules.

@Vamsi-klu

Copy link
Copy Markdown
Contributor Author

Local Java test run: FAILED — details

  • Commit: 7513ddc18bab (base origin/main)
  • The summary is in the PR description.

Failed: RequestLatencyContextTest#testTimingAccuracyWithKnownDurations

The unchanged timing test also missed its tolerance on pristine upstream under load. The targeted rerun on the branch passed. All 17 tests across the four changed unit suites passed.

Tests run locally

  • unit · openmetadata-service (5 classes): JettyMetricsIntegrationTest (3 passed), JettyMetricsTest (1 passed), MicrometerBundleTest (9 passed), RequestLatencyContextTest (17 passed, 1 failed), SearchIndexMetricsTest (4 passed)
  • integration · mysql-elasticsearch · parallel: PrometheusResourceIT (3 passed, 1 skipped)

Broader coverage not executed by this focused run

  • mvn -B package -pl openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=JettyMetricsIntegrationTest,JettyMetricsTest,MicrometerBundleTest,RequestLatencyContextTest,RequestMetricsFilterTest,SearchIndexMetricsTest -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel '-Dit.test=<568 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=global-state '-Dit.test=<59 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=rdf '-Dit.test=<38 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pcache-tests -DintegrationTests.lane=parallel -Dit.test=AlertStateIT,BundleWarmupCertificationIT,ContainerCacheCorrectnessIT,EntityCacheWriteOrderIT,OneTransactionFlushAtomicityIT,RelationshipCacheInvalidationIT,TagRenameCacheIT,UncachedReadIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pcache-tests -DintegrationTests.lane=global-state -Dit.test=CredentialRedisDownIT,CredentialRedisNoRoundTripIT,SessionRedisMultiNodeIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Ppostgres-opensearch -DintegrationTests.lane=parallel -Dit.test=FlattenedChildrenHighlightSearchIT,InheritedFieldPropagationRecoveryIT,OpenSearchEntityManagerDeleteByScriptRetryIT,UpdateChildrenAsyncPropagationIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Ppostgres-opensearch -DintegrationTests.lane=global-state -Dit.test=PatchTableEmbeddingIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Psearch-it -DdatabaseType=postgres -DsearchType=opensearch -Djpw.data.mode=ingest '-Dit.test=<37 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
Why these tests
  • added by author: verify canonical and legacy metrics through the actual scrape ← JettyMetricsIntegrationTest, JettyMetricsTest, MicrometerBundleTest, PrometheusResourceIT, RequestLatencyContextTest (+1 more)
Impacted, not run locally (15)
  • LineagePayloadScaleIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • LineageScenePerformanceScaleIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • OntologyScaleIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • ReindexBenchmarkIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • ReindexCpuHeadroomIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • Scale100kEntitiesIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • ServiceDeleteSearchCleanupScaleIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • TableTotalCountScaleIT → nightly: openmetadata-nightly k8s-java-it (scale-it)
  • LongCompoundNameSearchUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • PipelineOwnerIndexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • DistributedAutoTuneReindexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • SearchAvailableAllKindsDuringReindexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • SearchAvailableDuringReindexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • SelectiveFieldReindexUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
  • SimpleReindexTriggerUIIT → nightly: openmetadata-nightly k8s-java-it (ui-it + embedded JavaUIIT)
Commands
mvn -B package -pl openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=JettyMetricsIntegrationTest,JettyMetricsTest,MicrometerBundleTest,RequestLatencyContextTest,SearchIndexMetricsTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel -Dit.test=PrometheusResourceIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false

@Vamsi-klu
Vamsi-klu marked this pull request as ready for review November 27, 2026 20:12
@Vamsi-klu
Vamsi-klu requested a review from a team as a code owner November 27, 2026 20:12
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@pmbrull pmbrull left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues found

Blockers ✅ none
Nits ✅ none
Tests ✅ thread capacity, metric types, and GET/POST route grouping
Cross-repo ⚠️ deployed ServiceMonitor and dashboard queries still need staging verification
Trade-off ✅ justified: the route label changes because it collides with the scrape target’s endpoint label
Auto-approved ➖ maintainer sign-off on the scrape-label rollout and green metadata

Thanks for correcting the utilization denominator and providing queries for a mixed-version rollout.

Please record the staging scrape and dashboard check already listed in the PR. The rollout changes latency selectors from endpoint to http_route. The issue also needs to go into Shipping. Metadata check

What I checked

Reviewed the Jetty, exporter, diagnostics, and latency CLI changes. Ran the pinned CLI with http_route, endpoint, and exported_endpoint samples and checked that GET and POST keep their own counts, timings, and percentages. Backend CI passed. The author reports one local timing test failed on both the base and PR and passed on retry. The deployed scrape, dashboards, and wider impacted integration plan remain unverified.

claude-verdict {"sha":"7513ddc18bab4dd3c35e5cb682f5ef05072abda8","recommendation":"human","blocking":0,"nits_to_fix":0,"human_decision":true,"tradeoff":"holds","cross_repo":"could_not_check","tests_ok":true}

Copy link
Copy Markdown
Contributor Author

@pmbrull Thanks for calling out the rollout check. The required backend check passed on this head, and the local fixtures cover http_route and both legacy route labels. I don’t have access to the staging ServiceMonitor or dashboards from this environment, so the deployed scrape and dashboard queries still need a staging run. Backend check

@pmbrull

pmbrull commented Dec 3, 2026

Copy link
Copy Markdown
Member

hi @Vamsi-klu can you share a real sample of exported prometheus metrics before and after the change, so we can evaluate that this is properly fixed? Thanks

@Vamsi-klu

Copy link
Copy Markdown
Contributor Author

@pmbrull here is a real before and after sample. I ran main and this branch locally, sent the same 1183 requests to each, and scraped /prometheus with a local Prometheus v3.8.0. This is not staging; I have no access to it.

Before (main):

jetty_threads_busy 10.0
jetty_threads_current 100.0
jetty_threads_max 150.0
jetty_threads_utilization 10.0
# TYPE jetty_requests gauge
jetty_requests 1183.0
jetty_responses_2xx 1163.0
jetty_response_time_max 4.367380564E9
request_latency_total_seconds_count{endpoint="/v1/classifications",method="POST"} 70

After (this PR):

jetty_threads_busy 10.0
jetty_threads_current 100.0
jetty_threads_max 150.0
jetty_threads_utilization 6.666666666666667
jetty_threads_utilization_ratio 0.06666666666666667
# TYPE jetty_http_requests_total counter
jetty_http_requests_total 1183.0
jetty_http_responses_total{status_class="2xx"} 1163.0
jetty_response_time_max_seconds 4.067470816
request_latency_total_seconds_count{http_route="/v1/classifications",method="POST"} 70

What changed:

  • Thread utilisation divides by the configured max (150), not the allocated pool (100).
  • Cumulative counts are counters named _total, and the status class is a label.
  • Times are in seconds.
  • The route label is http_route. endpoint collided with the scrape target's own label: through Prometheus, main's series came back with exported_endpoint and this branch's did not.

Every old series is still exported. 12 families are added, none removed.

Not checked: the staging ServiceMonitor and dashboards. The one change they need is the latency selector, endpoint to http_route.

One open point: jetty_response_time_stddev was NaN on the branch run and had a value on main. I have not found why yet.

I can paste the full scrape files if that helps. Could #38509 be added to Shipping?

@gitar-bot

gitar-bot Bot commented Dec 6, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk

Renaming the exported latency route label from endpoint to http_route breaks existing scrape queries, which could omit route-level latency monitoring until rules migrate.

Corrects Jetty thread utilization to use configured capacity and adds conventional Prometheus counter types, units, and http_route labels alongside legacy families for a mixed-version rollout. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

This branch has not been deployed

No deployments
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.

[Metrics] Metric types, units and labels on /prometheus break Prometheus conventions; jetty_threads_utilization uses the wrong denominator

2 participants