Repository navigation
fix(monitoring): accept the Cloud Run metrics egress filter at Cloud Monitoring - #12099
Merged
Merged
Conversation
added 2 commits
August 23, 2026 13:42
…Monitoring The dedicated Stackdriver exporter added in #11998 has never imported a single series. Cloud Monitoring rejects a filter that mixes AND with OR across resource.labels restrictions, so every descriptor query returned HTTP 400 while the exporter stayed Available, its Prometheus target stayed up, and Grafana showed empty panels that read as no traffic. Express the namespace disjunction as one_of(...), which the filter grammar defines for this case. Keep the namespace scope: dropping it would import every omi_ series from every Cloud Run service in the project. Add omi-cloud-run-metrics-egress-query-rejected, alerting on the exporter's own upstream error rather than on its liveness. Extend the exporter contract test to cover the dev values file, which was unasserted and is what the automatic post-merge rollout installs. Correct the runbook's verification step, which queried the mangled metric name that a healthy deployment no longer produces.
…d resource The production-data-plane-routing guard exempts the Stackdriver egress values files from its retired-GKE-desktop-backend rule only when they contain the literal resource.labels.namespace="desktop-backend". That pins the exemption to one spelling of a filter rather than to what makes the file a Cloud Run observer, so rewriting the disjunction as one_of(...) to satisfy Cloud Monitoring's grammar made a read-only metrics reader look like retired GKE ownership. Key the exemption on resource.labels.cluster="__run__" instead. That is Cloud Run's reserved pseudo-cluster, so together with the prometheus.googleapis.com/ prefix it identifies the monitored resource directly and survives any future edit to the namespace set.
formed2forge
pushed a commit
to formed2forge/omi
that referenced
this pull request
Aug 24, 2026
…Monitoring (BasedHardware#12099) * fix(monitoring): accept the Cloud Run metrics egress filter at Cloud Monitoring The dedicated Stackdriver exporter added in BasedHardware#11998 has never imported a single series. Cloud Monitoring rejects a filter that mixes AND with OR across resource.labels restrictions, so every descriptor query returned HTTP 400 while the exporter stayed Available, its Prometheus target stayed up, and Grafana showed empty panels that read as no traffic. Express the namespace disjunction as one_of(...), which the filter grammar defines for this case. Keep the namespace scope: dropping it would import every omi_ series from every Cloud Run service in the project. Add omi-cloud-run-metrics-egress-query-rejected, alerting on the exporter's own upstream error rather than on its liveness. Extend the exporter contract test to cover the dev values file, which was unasserted and is what the automatic post-merge rollout installs. Correct the runbook's verification step, which queried the mangled metric name that a healthy deployment no longer produces. * fix(monitoring): key the Cloud Run observer exemption on the monitored resource The production-data-plane-routing guard exempts the Stackdriver egress values files from its retired-GKE-desktop-backend rule only when they contain the literal resource.labels.namespace="desktop-backend". That pins the exemption to one spelling of a filter rather than to what makes the file a Cloud Run observer, so rewriting the disjunction as one_of(...) to satisfy Cloud Monitoring's grammar made a read-only metrics reader look like retired GKE ownership. Key the exemption on resource.labels.cluster="__run__" instead. That is Cloud Run's reserved pseudo-cluster, so together with the prometheus.googleapis.com/ prefix it identifies the monitored resource directly and survives any future edit to the namespace set. --------- Co-authored-by: r <r@r>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Cloud Run metrics egress bridge added in #11998 has never imported a single series. The dedicated Stackdriver exporter is deployed and healthy in dev, its Prometheus target is up, and every one of its Cloud Monitoring queries returns HTTP 400. This makes the filter acceptable to Cloud Monitoring, and adds the alert that would have caught it on day one.
Cloud Monitoring rejects a filter that mixes
ANDwithORacrossresource.labelsrestrictions:The disjunction is now expressed as
one_of("backend","desktop-backend"), which the filter grammar defines for exactly this case. The namespace scope is kept: dropping it would import everyomi_*series from every Cloud Run service and job in the project, not justbackendanddesktop-backend.Why nothing caught this
The exporter answers the 400 per descriptor and stays Available. Its Prometheus target stays
up. The deploy workflow verifies Helm status, Deployment rollout, and Service existence. The one ingestion alert counts Stackdriver-mangled names, and a bridge that imports nothing produces no mangled names, so it sits green. The runbook's own verification step queried the mangled form, which returns zero on a healthy deployment — the check was inverted.Every signal in the path was scoped to the relay process rather than to its cargo, so 100% query failure rendered as an empty Grafana panel, which reads as no traffic.
Changes
dev_omi_cloud_run_metrics_exporter.yaml,prod_omi_cloud_run_metrics_exporter.yaml:one_of(...)filter.omi-cloud-run-metrics-egress-query-rejected— fires onstackdriver_monitoring_last_scrape_error > 0for the egress job for 15m. This is the signal that was missing; it would have fired 15 minutes after feat(monitoring): ingest Cloud Run application metrics #11998 rolled out.test_monitoring_telemetry_contract.py: the exporter contract now covers both environments (the dev file was entirely unasserted, and dev is what the automatic post-merge rollout installs), pins the corrected filter, and adds a narrow static tripwire for the mixedAND/ORshape. The tripwire is deliberately not called a grammar check: it does not parse the filter language and does not call Cloud Monitoring.stackdriver_monitoring_last_scrape_error == 0and a non-zero count of plainomi_*names, and states whyupis not proof.Live evidence
Gathered against
based-hardware-devandbased-hardwarebefore this change:dev-omi-cloud-run-metrics-exporterDeploymentup{job="cloud-run-application-metrics"}stackdriver_monitoring_api_calls_totalon that jobstackdriver_monitoring_last_scrape_erroron that jobomi_*series on that jobCandidate filters tested directly against the Cloud Monitoring v3
timeSeriesAPI, 20m window,view=HEADERS:AND+ORmixed... AND resource.labels.namespace=one_of("backend","desktop-backend")... AND resource.labels.cluster="__run__"onlymetric.typeonly, no resource restrictionReturned series carry
resource.type=prometheus_target,resource.labels{cluster="__run__", namespace="backend", job="omi-cloud-run-application-metrics"}andmetric.labels{journey, outcome, service_name, client_kind}— confirming thestackdriver_prometheus_target_prometheus_googleapis_com_prefix the scrape job's rewrite regex expects.Product invariants affected
The routing guard change touches no serving authority. It widens nothing about where any client is routed: it replaces one over-specific literal in an exemption marker (
resource.labels.namespace="desktop-backend") with the monitored-resource literal that actually identifies Cloud Run (resource.labels.cluster="__run__"), so a read-only metrics reader stops being classified as retired GKE desktop-backend ownership. Every production-family routing pin, and the retired-GKE rule itself, is unchanged;test_current_config_is_pinnedstill validates the live tree, and all 12 guard tests pass.Verification
test_monitoring_telemetry_contract.py,test_monitoring_alert_rule_contract.py,test_journey_observability.py,test_cloud_run_metrics_egress_workflow.py:53 passedblack --line-length=120 --skip-string-normalization: unchanged.ruff --target-version py39: clean.alert-rules.jsonverified structurally, not by reading the diff: 72 → 73 rules, exactly one uid added, zero pre-existing rules altered, order preserved, and the split source inalerts/cloud-run-ingestion.jsonbyte-identical to the combined entry.Not in this PR
backend/charts/monitoring/README.md, prod is the live source, so merging this does not make the rule fire; it is provisioned separately.backend-465cd0f-32620507075-1went Ready then retired at 0% traffic), so prod Cloud Monitoring has noomi_*descriptors at all yet. That is a rollout state, not a defect, and it is unblocked by the normal deploy workflows.Review
Diagnosis, the
one_of()repair, the rewrite regex, the rollout sequence, and the failure-class choice were independently reviewed by GPT-5.6 (codex) against this checkout. Its corrections are folded in: the tripwire test was renamed to stop overclaiming, the runbook query was inverted back, the egress-error alert was added, and the plan to hand-promote the retired prod revision was dropped in favour of the deploy workflows, which already do candidate → validate → promote → verify → roll back.Failure-Class: new