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

Question:
You are instrumenting an HTTP API with Prometheus metrics. You want to define a metric that tracks the number of failed client HTTP requests (status code 4xx) and failed server HTTP requests (status code 5xx).
Which of the following metric names and labels is the MOST appropriate?

  1. http_4xx_requests (no labels) and http_5xx_requests (no labels)
  2. http_requests_total (status_code label)
  3. http_4xx_requests_total (no labels) and http_5xx_requests_total (no labels)
  4. http_requests (status_code label)
Answer:
B - correct answer, it is a Prometheus naming best practice to use labels to differentiate the characteristics of the thing being measured (such as the status code), also it is a Prometheus naming best practice to name accumulating count metrics with a suffix total