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

Question:
Let http_requests_total be a counter metric representing the number of requests that have hit a given type of web server. Assume there are multiple instances of this type of server. Let this metric have a label called status_code where the values are HTTP status codes (200, 201, 404, etc).
Which of the following queries yields the total 5-minute rate of requests from exactly one day prior?

  1. rate(http_requests_total{status_code="*"}[1d])
  2. sum(rate(http_requests_total[5m] offset 1d))
  3. sum_over_time(http_requests_total[1d])
  4. sum(rate(http_requests_total[5m])) offset 1d
Answer:
B - is the correct answer
A - is incorrect as status_code="*" will not actually match any of the series. Additionally, this query does not aggregate to provide the total rate nor does it provide the rate from one day prior
C - is incorrect as temporal aggregations such as sum_over_time act on each series individually. We want the total rate across all dimensions (instances and status codes) so we need to use a dimensional aggregation like sum instead
D - is incorrect as the offset modifier must directly follow the selector, it cannot follow a function call or aggregation