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

Question:
Which of the following PromQL expressions is equivalent to sum(rate(requests_total[5m])) by (job)?

  1. increase(requests_total[5m]) by (job)
  2. rate(requests_total[5m]) by (job)
  3. sum_over_time(requests_total[5m]) by (job)
  4. avg(rate(requests_total[5m))) by (job)
Answer:
B - is correct answer. The rate function calculates the per-second rate of increase of a counter over a specified time range. The sum function calculates the sum of all values of a metric vector. The by clause groups the metric by the specified label. Therefore, sum(rate(requests_total[5m])) by (job) calculates the sum of the per-second rate of increase of the requests_total counter over the past 5 minutes, grouped by the job label. This is equivalent to rate(requests_total[5m]) by (job)