PCA practice question 7 of 15
Which PromQL expression computes the rate of API Server requests across the different cloud providers from the following metrics? apiserver_request_total{job="kube-apiserver", instance="192.168.1.220:6443", cloud="aws"} 1 apiserver_request_total{job="kube-apiserver", instance="192.168.1.121:6443", cloud="gcloud"} 5
Full set: 60 questionsThe goal is to compute the rate of requests aggregated by the cloud label. The correct approach is to first calculate the per-second rate for each individual time series using rate(apiserverrequesttotal[5m]). This function operates on the apiserverrequesttotal counter over a 5-minute window. The result is an instant vector of rates. Subsequently, the sum() by (cloud) aggregation operator is applied to this vector of rates. This sums up the rates for all instances belonging to the same cloud provider, effectively giving the total request rate per cloud.
A. rate(apiserverrequesttotal{job="kube-apiserver"}[5m]) by (cloud) This is syntactically incorrect. The by (cloud) clause is a modifier for an aggregation operator (like sum or avg), not for the rate() function itself.
B. sum by (cloud) (apiserverrequesttotal{job="kube-apiserver"}) This query sums the raw counter values, not their rate of change. It would return the total number of requests at a single point in time, which is not a rate.
D. rate(sum by (cloud)(apiserverrequesttotal{job="kube-apiserver"})[5m]) This is syntactically incorrect. The range vector selector [5m] can only be applied to an instant vector selector (e.g., a metric name), not to the output of an aggregation function like sum().
1. Prometheus Official Documentation, "Querying basics": This document explains the different selector types. It clarifies that a range-vector selector [5m] is appended to an instant-vector selector to select a range of samples. This invalidates option D, where [5m] is applied to a function's output.
Source: Prometheus Documentation, Querying, Basics. Section: "Range Vector Selectors".
2. Prometheus Official Documentation, "Querying functions": The documentation for the rate() function states that it "calculates the per-second average rate of increase of the time series in the range vector." This confirms rate() is the correct function to use on a counter metric like apiserverrequesttotal.
Source: Prometheus Documentation, Querying, Functions. Section: "rate()".
3. Prometheus Official Documentation, "Querying operators": This page details aggregation operators. It shows the correct syntax is by () (), such as sum by (cloud) (...). This confirms that the aggregation in option C is performed correctly on the result of the rate() function.
Source: Prometheus Documentation, Querying, Operators. Section: "Aggregation operators".
Keep practicing
Take the free PCA practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other PCA practice questions
- Question 1What function calculates the tp-quantile from a histogram?
- Question 2How can you select all the up metrics whose instance label matches the regex fe-.*?
- Question 3Which exporter would be best suited for basic HTTP probing?
- Question 4What Prometheus component would you use if targets are running behind a Firewall/NAT?
- Question 5What is the name of the official *nix OS kernel metrics exporter?
- Question 6Which function would you use to calculate the 95th percentile latency from histogram data?
