Skip to main content

Google Cloud Monitoring

In brief: Export low-cardinality OpenTelemetry route metrics to Google Managed Service for Prometheus, then connect TestChimp with a read-only service account.

The Google Cloud Monitoring integration reads route-level RED metrics from Google Managed Service for Prometheus using PromQL.

Cloud Run and API Gateway infrastructure metrics alone do not identify OpenAPI route templates. Generate route metrics from OpenTelemetry server spans before connecting.

Prerequisites

  • Enable monitoring.googleapis.com and telemetry.googleapis.com.
  • Instrument services with server spans containing:
    • service.name
    • http.route
    • http.request.method or legacy http.method
    • http.response.status_code or legacy http.status_code
  • Run the OpenTelemetry Collector Contrib distribution with the spanmetrics connector and googlemanagedprometheus exporter.
  • Grant the collector identity roles/monitoring.metricWriter.
  • Create a dedicated TestChimp reader identity with roles/monitoring.viewer.

Required metric contract

The TestChimp adapter queries:

  • testchimp_route_calls_total
  • testchimp_route_duration_milliseconds_bucket

Required labels are:

  • service_name
  • http_request_method
  • http_route
  • http_response_status_code
  • status_code

Use a 60-second spanmetrics flush interval, explicit bounded latency buckets, and a cardinality limit. Filter out non-server spans and spans without http.route. Never fall back to concrete url.path values.

Collector outline

connectors:
spanmetrics/route:
namespace: testchimp.route
dimensions:
- name: http.request.method
- name: http.route
- name: http.response.status_code
histogram:
explicit:
buckets: [5ms, 10ms, 25ms, 50ms, 100ms, 250ms, 500ms, 1s, 2.5s, 5s, 10s]
aggregation_cardinality_limit: 10000
metrics_flush_interval: 60s

exporters:
googlemanagedprometheus:
project: "YOUR_GCP_PROJECT_ID"

The metrics pipeline also needs valid GMP target resource attributes such as location, cluster, and namespace.

Create the read-only identity

gcloud iam service-accounts create testchimp-observability-reader \
--project=YOUR_GCP_PROJECT_ID

gcloud projects add-iam-policy-binding YOUR_GCP_PROJECT_ID \
--member="serviceAccount:testchimp-observability-reader@YOUR_GCP_PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/monitoring.viewer"

The current TestChimp connection supports a service-account JSON key. Create it into a temporary protected file, paste it into TestChimp, and delete the local file immediately:

umask 077
KEY_FILE="$(mktemp /tmp/testchimp-observability-reader.XXXXXX.json)"

gcloud iam service-accounts keys create "$KEY_FILE" \
--project=YOUR_GCP_PROJECT_ID \
--iam-account="testchimp-observability-reader@YOUR_GCP_PROJECT_ID.iam.gserviceaccount.com"

Do not print, commit, email, or attach the JSON key to a support request.

Configure TestChimp

In Project Settings → Integrations → Observability:

  1. Select Google Cloud Monitoring.
  2. Enter the GCP project ID receiving the metrics.
  3. Paste the complete Service account JSON.
  4. Choose Test Connection.
  5. Save the connection.
  6. In APIs, map each OpenAPI service to its matching discovered service_name.

After saving successfully, securely remove the temporary key file and clear any clipboard containing it.

Validation

In Google Cloud, confirm this PromQL query returns route series:

sum by (service_name, http_request_method, http_route, status_code)
(testchimp_route_calls_total)

If TestChimp discovers no resources:

  • wait at least one 60-second flush interval;
  • generate traffic to a templated route;
  • confirm the collector has roles/monitoring.metricWriter;
  • confirm the reader has roles/monitoring.viewer; and
  • inspect collector logs for rejected GMP target metadata.

Cost and cardinality

Google Managed Service for Prometheus charges for ingested samples. Every combination of service, method, route, status, and histogram bucket creates series. Route templates, bounded buckets, a 60-second interval, and a cardinality limit keep ingestion predictable.

FAQ

Can Cloud Run metrics identify OpenAPI routes?

Not by themselves. TestChimp requires route metrics generated from OpenTelemetry spans with http.route and HTTP method attributes.

Which GCP role does the TestChimp reader need?

Grant the dedicated reader service account roles/monitoring.viewer.

Which metrics does TestChimp query?

testchimp_route_calls_total and testchimp_route_duration_milliseconds_bucket in Google Managed Service for Prometheus.