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

Question:
Which of the following PromQL expressions would give the number of HTTP 500 errors for a specific endpoint in the last hour?

  1. rate(http_requests_total{status_code="500", endpoint="/my-endpoint"}[1h])
  2. sum(http_requests_total{status_code="500", endpoint="/my-endpoint"}[1h])
  3. count(http_requests_total{status_code="500", endpoint="/my-endpoint"}[1h])
  4. delta(http_requests_total{status_code="500", endpoint="/my-endpoint"}[1h])
Answer:
B - correct answer. The sum aggregation function is used to add up all the values in the input range vector. In this case, we want to sum up the number of HTTP 500 errors for a specific endpoint in the last hour. Therefore, the correct PromQL expression is with sum