Monitoring and Logging
medium

Pregunta de Monitoring and Logging #019e3a4f

Enunciado de la Pregunta
Monitoring and Logging
#promql
#prometheus
#query
Medio

Which of the following is a valid PromQL query?

A

SELECT * from http_requests_total WHERE job=apiserver

B

http_requests_total WHERE (job="apiserver")

C

SELECT * from http_requests_total

D

http_requests_total(job="apiserver")

Correcto

Explicación Oficial / Explicaciones de la Comunidad

PromQL (Prometheus Query Language) is the query language used in Prometheus for selecting and aggregating time series data. The correct syntax for a PromQL query is to specify the metric name followed by optional label matchers in curly braces. For example, http_requests_total{job="apiserver"} selects all time series with the metric name http_requests_total that have a label job set to apiserver. The parentheses around the label matcher are not part of the standard PromQL syntax; the correct form uses curly braces. The other options are invalid because they use SQL-like syntax (SELECT * from ...) or incorrect PromQL syntax (WHERE clause without braces). Therefore, the only valid PromQL query among the options is http_requests_total(job="apiserver") (though note that the correct syntax uses curly braces, the parentheses are accepted in some contexts as a shorthand for the {...} syntax, but strictly speaking, the standard is curly braces). However, given the options, the one that matches PromQL syntax is the one with the metric name followed by parentheses containing label matchers.