KCNA · Question #70
Which of the following is a valid PromQL query?
The correct answer is D. http_requests_total(job="apiserver"). PromQL (Prometheus Query Language) uses a specific syntax for metric selection and filtering, where filters are enclosed in curly braces.
Question
Which of the following is a valid PromQL query?
Options
- ASELECT * from http_requests_total WHERE job=apiserver
- Bhttp_requests_total WHERE (job="apiserver")
- CSELECT * from http_requests_total
- Dhttp_requests_total(job="apiserver")
How the community answered
(38 responses)- A3% (1)
- B3% (1)
- C8% (3)
- D87% (33)
Why each option
PromQL (Prometheus Query Language) uses a specific syntax for metric selection and filtering, where filters are enclosed in curly braces.
PromQL does not use SQL-like keywords such as `SELECT * from` or `WHERE` for querying metrics.
This syntax mixes the metric name with a `WHERE` clause, which is not valid PromQL; label selectors are enclosed in curly braces.
PromQL does not use `SELECT * from`; a metric name alone like `http_requests_total` is a valid basic query, but `SELECT * from` is incorrect syntax.
In PromQL, metric selectors use curly braces `{}` to specify label matchers. `http_requests_total` selects the metric, and `{job="apiserver"}` filters the results to only include those where the `job` label has the value `apiserver`, which is the correct syntax for a metric selector.
Concept tested: PromQL query syntax
Source: https://prometheus.io/docs/prometheus/latest/querying/basics/#metric-selectors
Topics
Community Discussion
No community discussion yet for this question.