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

Question:
You are instrumenting an HTTP API with Prometheus metrics. You want to be able to get the rate in requests per day made to your API.
What is the BEST way to accomplish this?

  1. Define a gauge metric called http_requests_per_day, query directly via PromQL
  2. Define a counter metric called http_requests_total, use the PromQL rate function to calculate the requests per day
  3. Define a counter metric called http_requests_total, use the PromQL rate function to calculate the requests per second and multiply by 86400 to get the per-day request rate
  4. Define a counter metric called http_requests_total, use the PromQL rate function to calculate the requests per second and divide by 86400 to get the per-day request rate
Answer:
C - is the correct answer
A - is incorrect as it is an instrumentation best practice to expose the most "raw" metric possible and perform desired calculations in PromQL. This increases the flexibility of the metric
B - is incorrect as the PromQL rate function returns the per-second rate, not the per-day rate
D - is incorrect as it is necessary to multiply by 86400, not divide. With the base unit as requests per second returned from rate, to cancel the seconds we need to multiply by a quantity where seconds is the unit of the numerator and days is the unit of the denominator. The quantity that matches this need is "86400 seconds per day". When we multiply the two quantities together the seconds will cancel and we are left with a unit of requests per day. This process is a mathematical concept called dimensional analysis. You can learn more about it at the third reference link below