PCA practice question 8 of 15

Which of the following is an invalid @ modifier expression?

Full set: 60 questions
Answer options
A: go_goroutines @ start()
B: sum(http_requests_total{method="GET"}) @ 1609746000
C: go_goroutines @ end()
D: sum(http_requests_total{method="GET"} @ 1609746000) Correct answer
Correct Answer:
D. sum(http_requests_total{method="GET"} @ 1609746000)
Explanation

The @ modifier in PromQL is used to change the evaluation time for an expression. When used with aggregation operators such as sum(), the canonical and syntactically correct method is to apply the modifier to the entire aggregation expression. The expression sum(httprequeststotal{method="GET"}) @ 1609746000 correctly evaluates the sum() function as if the current time were the specified timestamp. The syntax in option D, sum(httprequeststotal{method="GET"} @ 1609746000), which places the @ modifier on the instant vector selector inside the aggregation function, is not the standard syntax for this operation and is considered invalid.

Why Incorrect

A. This is a valid expression. The start() function is used with the @ modifier to evaluate the expression at the start time of a range query.
B. This is the correct and valid syntax for evaluating an aggregation at a specific Unix timestamp. The @ modifier is correctly applied to the entire sum() expression.
C. This is a valid expression. The end() function is used with the @ modifier to evaluate the expression at the end time of a range query.

References

1. Prometheus Official Documentation, "Querying > Basics", @ modifier section. This section outlines the primary uses of the @ modifier. It can be applied to an instant vector selector (metric @ timestamp) or to a full expression. For aggregations, the standard is to apply it to the entire expression to set the evaluation time for the whole operation, as shown in option B. The syntax in option D is non-canonical for aggregations.

Source: https://prometheus.io/docs/prometheus/latest/querying/basics/#modifier

2. Prometheus Official Documentation, "Querying > Operators", "Aggregation operators" section. The syntax for aggregation operators is defined as aggr-op([parameter,] ). This implies that modifiers which affect the evaluation time of the entire operation, like @, should be applied to the complete aggr-op(...) construct, not to the argument within it.

Source: https://prometheus.io/docs/prometheus/latest/querying/operators/#aggregation-operators

Scroll to Top