PCDOE Implementing service monitoring strategies Practice Question
Exhibit
Refer to the exhibit.
```
# prometheus.yml
scrape_configs:
- job_name: 'my-app'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_label_app]
regex: my-app
action: keep
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
regex: "true"
action: keep
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_port]
action: replace
target_label: __address__
regex: (.+)
replacement: $1:8080
```A team has deployed a Prometheus server on GKE using the configuration above. They expect Prometheus to scrape metrics from pods with the label 'app: my-app' and the annotation 'prometheus.io/scrape: true' on port 8080. However, no metrics are being collected. What is the most likely cause?
⚠ Common exam trap
The trap here is that candidates often overlook the relabel_config port construction and assume the issue is with service discovery roles or label filtering, when in fact the static port override is the subtle cause of scrape failures.
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
✓
The relabel_config for port incorrectly constructs the target address; it should use the annotation value directly without appending ':8080'.
The relabel_config is incorrectly constructing the target address. The configuration likely uses `__meta_kubernetes_annotation_prometheus_io_port` to get the port, but then appends ':8080' statically, overriding the annotation value. If the annotation specifies a different port or is missing, this hardcoded port causes Prometheus to scrape the wrong endpoint or fail entirely. The correct approach is to use the annotation value directly without appending a fixed port, or to use a default port only when the annotation is absent.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The kubernetes_sd_configs role is set to 'pod' but should be 'endpoints'.
Why it's wrong here
Role 'pod' is correct for scraping pods directly.
- ✗
Prometheus needs to be configured to listen on port 9090 for scraping.
Why it's wrong here
Prometheus listens on 9090 for its UI, not for scraping; scraping uses the target port.
- ✗
The keep action for the label 'my-app' is filtering out all pods.
Why it's wrong here
If the label is correct, pods are kept.
- ✓
The relabel_config for port incorrectly constructs the target address; it should use the annotation value directly without appending ':8080'.
Why this is correct
The port annotation usually includes the port number, so appending a fixed port is wrong.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCDOE question from scratch — 486 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
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.