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

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, 503, etc).
Which of the following queries yields the approximate total number of good requests (200 - 299) in the past day?

  1. sum(rate(http_requests_total{status_code=~`2\d\d`}[1d]))
  2. sum_over_time(http_requests_total{status_code="2xx"}[1d])
  3. sum(increase(http_requests_total{status_code=~`2\d\d`}[1d]))
  4. http_requests_total{status_code=~`2\d\d`}
Answer:
C - is the correct answer. More at increase and aggregation-operators
A - is incorrect as this query results in a rate of requests whereas the question asks for a number of requests
B - is incorrect for several reasons. First, the label selector does not use a regular expression to target all of the good requests. Secondly, it sums the counter over time which will not provide the desired result. Instead, it is necessary to apply the increase function first and then apply the regular sum function across all dimensions to get the total number of good requests. The result is approximate because the increase function extrapolates across the time interval
D - is incorrect as this query gives the current number of requests held by the counter for each 200-series status code. Since we do not know when this counter started counting, this query will not be able to reliably give the number of requests over the past day. Additionally, the query does not aggregate the count of good requests to provide a singular result