Prepare and test your skills
Prepare and test your skills
Free sample question, answered and explained below. The Professional Cloud DevOps Engineer practice bank has 1,455 more like it. Try 10 free: instant score, no account.
Your team manages microservices deployed on Google Kubernetes Engine (GKE) and collects telemetry using Google Cloud Managed Service for Prometheus with managed collection. A recent FinOps review in the Cloud Monitoring Metrics Management page reveals a major cost spike attributed to custom metric ingestion volume.
Upon investigation, you identify two main drivers:
user_id label dimension across millions of user sessions.You need to optimize observability costs by decreasing the scraping frequency to 30 seconds and stripping the high-cardinality user_id label before samples are ingested into the backend, without altering the application code.
Which configuration should you apply to the PodMonitoring custom resource?
spec, set scrape_interval: 30s and add an Ops Agent processors block of type exclude_metrics matching metric_pattern: user_id.The Google Cloud Ops Agent configuration syntax is used on Compute Engine VMs to collect system telemetry, logs, and third-party metrics. In Ops Agent configurations, a processors block with type: exclude_metrics filters out entire metric names from being written to Cloud Monitoring.
PodMonitoring CRDs (monitoring.googleapis.com/v1) rather than the VM-level Ops Agent config.yaml.PodMonitoring custom resources do not support processors blocks or exclude_metrics fields. Applying this YAML will result in a Kubernetes schema validation error.exclude_metrics drops the entire metric stream rather than stripping an individual label dimension to preserve aggregate visibility.The workload were running on Compute Engine VMs with the Ops Agent installed, and the objective was to completely discard an entire process or custom metric domain.
spec.endpoints, set interval: 30s and add a metricRelabeling rule with action: labeldrop and regex: user_id.In Google Cloud Managed Service for Prometheus (GMP), managed collection relies on Kubernetes Custom Resources such as PodMonitoring and ClusterPodMonitoring to define scraping targets and ingestion configurations. The metricRelabeling section implements standard Prometheus relabeling rules (metric_relabel_configs) applied to scraped samples immediately before they are ingested into the global Monarch datastore.
spec.endpoints[].interval to 30s reduces the collection frequency from 12 samples per minute to 2 samples per minute per time series, resulting in an immediate 83.3% reduction in baseline sample ingestion rate.action: labeldrop with regex: user_id in the metricRelabeling pipeline removes the user_id label from the scraped metric samples prior to storage. This aggregates the remaining dimensions and collapses millions of ephemeral time series into a small set of persistent streams.keep, drop, labeldrop, and labelkeep.PodMonitoring resources can be versioned and deployed automatically via standard Kubernetes CI/CD and Terraform workflows.This configuration directly targets the two core drivers of observability costs in sample-metered environments: sample ingestion frequency and active time series cardinality. Modifying the PodMonitoring custom resource is the native, Google-recommended approach for managed collection on GKE.
spec.endpoints, set interval: 30s and configure PromQL recording rules in Cloud Monitoring to aggregate away user_id at query time.PromQL queries in Cloud Monitoring dashboards, alerting policies, or recording rules allow users to run functions like sum without (user_id) (http_requests_total) to aggregate metric streams and remove high-cardinality dimensions when visualizing data.
Ingestion costs were negligible and the team only needed to simplify chart visualizations or alerting policy expressions in the Cloud Monitoring console without dropping backend data.
spec.endpoints, set interval: 30s and configure targetLabels.fromPod to exclude the user_id pod metadata label.The targetLabels field in a PodMonitoring custom resource provides target relabeling capabilities during target discovery. It copies specific Kubernetes Pod metadata labels (such as Kubernetes deployment names or environment tags defined on the pod spec) onto all metrics scraped from that pod as target labels.
targetLabels only controls pod-level Kubernetes metadata attached to the scrape target. It cannot inspect, filter, or strip metric labels emitted internally by the application exporter on the HTTP endpoint (such as user_id).user_id label on its custom metrics, the Managed Service for Prometheus collector will continue to ingest every unique user_id permutation, leaving the high-cardinality ingestion bill unaddressed.The goal were to prevent unwanted Kubernetes cluster pod labels (e.g., dynamic pod hashes or ephemeral pod deployment IDs) from being mapped to target labels on scraped metrics.
Answer them yourself and get your score the moment you finish. No account needed.
Full access includes
Keep the momentum going with these hand-picked practice scenarios
Last updated Validated