PCA practice question 13 of 15

Which PromQL statement returns the average free bytes of the filesystems over the last hour?

Full set: 60 questions
Answer options
A: avg_over_time(node_filesystem_avail_bytes[1h]) Correct answer
B: avg(node_filesystem_avail_bytes[1h])
C: sum(node_filesystem_avail_bytes[1h])
D: sum_over_time(node_filesystem_avail_bytes[1h])
Correct Answer:
A. avg_over_time(node_filesystem_avail_bytes[1h])
Explanation

The PromQL function avgovertime() is specifically designed to calculate the average value of all data points within a specified time interval for each time series. The query avgovertime(nodefilesystemavailbytes[1h]) correctly applies this function to the nodefilesystemavailbytes metric, which is a gauge representing available disk space. The [1h] is a range vector selector that specifies the time duration—one hour—over which the average should be calculated. This directly answers the question of finding the average free bytes over the last hour.

Why Incorrect

B. avg(nodefilesystemavailbytes[1h]) This syntax is invalid. The avg() aggregation operator works on instant vectors to average across different time series at a single point in time, not on range vectors ([1h]).
C. sum(nodefilesystemavailbytes[1h]) This syntax is also invalid. The sum() aggregation operator, like avg(), is used with instant vectors, not range vectors, to sum values across series at one point in time.
D. sumovertime(nodefilesystemavailbytes[1h]) This function calculates the sum of all data points over the specified time interval, not the average as required by the question.

References

1. Prometheus Official Documentation, Querying Functions: The documentation for avgovertime(range-vector) states it "calculates the average value of all points in the specified interval." This directly supports the correct answer A.

Source: Prometheus Authors. (n.d.). Querying functions. Prometheus. Retrieved from https://prometheus.io/docs/prometheus/latest/querying/functions/#avgovertime

2. Prometheus Official Documentation, Aggregation Operators: This section explains that operators like sum() and avg() are used to "aggregate the elements of a single instant vector, resulting in a new vector with fewer elements." It clarifies that they cannot be directly applied to a range vector [1h], making options B and C syntactically incorrect.

Source: Prometheus Authors. (n.d.). Aggregation operators. Prometheus. Retrieved from https://prometheus.io/docs/prometheus/latest/querying/operators/#aggregation-operators

3. Prometheus Official Documentation, Range Vector Selectors: This page defines a range vector as a set of time series containing a range of data points over time, denoted by a time duration in square brackets []. Functions like avgovertime operate on these, while aggregation operators like avg do not.

Source: Prometheus Authors. (n.d.). Range Vector Selectors. Prometheus. Retrieved from https://prometheus.io/docs/prometheus/latest/querying/basics/#range-vector-selectors

Scroll to Top