PCA (Prometheus Certified Associate) sample exam question with answer 352
Question:
Let a Node Exporter scrape job be denoted by the label job="node". Assume there are many instances of this scrape.
Which of the following queries yields the average duration of the last scrape across all instances?
- avg(timestamp(up{job="node"}))
- avg_over_time(scrape_duration_seconds{job="node"}[1m])
- avg(scrape_duration_seconds{job="node"})
- avg by (instance) (scrape_duration_seconds{job="node"})
Answer:
C - correct answer
A - is incorrect as the timestamp function yields the Unix timestamp of when the given series was collected. We want the duration of the scrapes so we should instead be using the Prometheus-provided scrape_duration_seconds metric
B - is incorrect as temporal aggregations like avg_over_time function on individual series. We desire to calculate the average across instances (a dimension) so we should instead use the avg dimensional aggregation
D - is incorrect as averaging by the instance label yields a resulting average for each instance. We desire to calculate the average across all instances so we should omit the by clause