Prometheus QL get the first values from the query result

12/24/2020

I write the query below to get the up time for the microvices.

base_jvm_uptime_seconds{kubernetes_name="namepspce1"}

However, it returns multiple values, so the grafana returns "Only queries that return single series/table is supported". I am wondering how can I the first velus from the query result?

I tried base_jvm_uptime_seconds{kubernetes_name="namepspce1"}[0], but it doesn't work..

Thanks!

-- user3464179
grafana
kubernetes
prometheus
promql

1 Answer

12/29/2020

I suggest you first inspect the label values of these multiple time series by running the query in Prometheus Graph console. The you'll need to decide which one you want to display. Random first usually isn't the best idea. But you can always do topk(1,query) if it helps. Just turn the Instant mode on in the Grafana Query editor.

-- sskrlj
Source: StackOverflow