Courseiva
Implementing service monitoring strategieshardMultiple ChoiceObjective-mapped

PCDOE Implementing service monitoring strategies Practice Question

Exhibit

Refer to the exhibit.
```yaml
apiVersion: monitoring.googleapis.com/v1
kind: ServiceMonitor
metadata:
  name: my-service-monitor
  namespace: default
spec:
  selector:
    matchLabels:
      app: my-app
  endpoints:
  - port: http
    interval: 30s
  namespaceSelector:
    matchNames:
    - production
  sampleLimit: 1000
  targetLabels:
  - instance
  metricRelabelings:
  - sourceLabels: [__name__]
    regex: 'container_.*'
    action: drop
```

Refer to the exhibit. What is the effect of the metricRelabelings section in this ServiceMonitor?

⚠ Common exam trap

Google Cloud often tests the distinction between `drop` and `keep` actions in relabeling configs, and the trap here is that candidates confuse 'drop' with 'keep' or mistakenly think `metricRelabelings` adds or renames labels instead of filtering metrics.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

It drops all metrics whose name starts with 'container_'.

The `metricRelabelings` section in a ServiceMonitor uses Prometheus relabeling rules to modify or filter metrics before ingestion. The `action: drop` directive, combined with a `regex: 'container_.*'` pattern matching the metric name, causes all metrics whose names start with 'container_' to be dropped (i.e., not scraped). This is a common pattern to exclude unwanted metrics and reduce cardinality.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • It adds a label called 'container_' to all metrics.

    Why it's wrong here

    metricRelabelings modifies metric labels, but here it drops based on __name__.

  • It only keeps metrics whose name starts with 'container_'.

    Why it's wrong here

    The action is drop, so it removes matching metrics, not keeps them.

  • It renames all metrics with the prefix 'container_' to remove the prefix.

    Why it's wrong here

    The action is 'drop', not 'replace' or 'keep'.

  • It drops all metrics whose name starts with 'container_'.

    Why this is correct

    The drop action with regex 'container_.*' removes matching metrics.

About these practice questions

This PCDOE question is part of Courseiva's 486-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This PCDOE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCDOE exam.