PCA (Prometheus Certified Associate) sample exam question with answer 351

Question:
Say you have a dynamic etcd database that contains scrape targets for Prometheus. How should you configure service discovery in this scenario?

  1. Write a program that periodically retrieves the targets from etcd and writes them to files according to the static_configs schema. Configure the scrape job to reference those files via file_sd_configs
  2. Write a program that periodically retrieves the targets from etcd and writes them to static_configs in the scrape configuration
  3. Use the built-in etcd_sd_configs scrape attribute
  4. Use the built-in kubernetes_sd_configs scrape attribute
Answer:
A - is the correct answer. More here
B - is incorrect as writing into the configuration file and using static_configs is much more burdensome than simply writing target files and leveraging file_sd_configs
C - is incorrect as there is no etcd service discovery built-in to Prometheus
D - is incorrect as Kubernetes service discovery is for discovering and scraping Kubernetes primitives such as pods. Though etcd is an integral part of a Kubernetes setup, it also has other uses. There is no indication in the question that this etcd setup is being used as part of a larger Kubernetes setup. Even if it was, kubernetes_sd_configs still would not be able to extract the targets from etcd and provide them to Prometheus