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

Question:
How can a custom exporter be registered with Prometheus?

  1. By using the start_http_server() function in the prometheus_client.exposition module
  2. By creating an instance of the CollectorRegistry class in the prometheus_client.registry module and registering the custom exporter with it
  3. By adding the custom exporter to the default_registry object in the prometheus_client.core module
  4. By exposing the metrics in the Prometheus exposition format on a specified port using a web server of your choice
Answer:
B - is correct
A - is incorrect as the start_http_server() function only starts a web server that serves metrics from the default_registry object
C - is incorrect as the default_registry object in the prometheus_client.core module is used as a global registry for collecting metrics
D - is incorrect as it describes the basic functionality of serving metrics over HTTP using a web server, but does not specify how to register a custom exporter with Prometheus