Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] capability to choose between Prometheus "query" and "query_range" API for table #5765

Closed
askannon opened this issue Aug 10, 2016 · 9 comments · Fixed by #9186

Comments

@askannon
Copy link

Grafana: 3.1.1 (docker image)
Prometheus: 1.0.1 (docker image)

I have the following Prometheus query:

topk(5, sum(rate(jaxrs_client_proxy_latency_seconds_sum[1h])) by (proxy, method))

When I run this in the Prometheus console I get a nice and simple "top 5"-style table because it is using the "/api/v1/query" endpoint on Prometheus. Now when I go to Grafana and add a "Table" and put the same query in I end up with a time series that I don't want/need because it is using the "/api/v1/query_range".

It would be great if - at least for the table element - it would be possible to choose what endpoint to use on Prometheus so that I can decide if I want to deal with a time series result or a simple table. Not only would it display the data that I am looking for but the "/api/v1/query" endpoint is responding about 10 times faster to the query than the "/api/v1/query_range" endpoint.

@ma05k1
Copy link

ma05k1 commented Oct 26, 2016

Agreed +1

@icholy
Copy link

icholy commented Oct 26, 2016

Does #6140 solve this?

@askannon
Copy link
Author

@icholy yes and no.

yes: #6140 is implementing access to the instant query API that I also need to use
no: the way #6140 is implementing it doesn't work for my use-case because I can't freely choose between what API to query

If #6140 could implement instant API usage trough some kind of choice in the Prometheus query editor instead of auto detecting it through "interval === 0" then it would solve my issue.

@mtanda
Copy link
Collaborator

mtanda commented Apr 7, 2017

@torkelo Would you add label "Prometheus" to this issue.

@mtanda
Copy link
Collaborator

mtanda commented May 4, 2017

Just a memo about Prometheus implementation.

The difference of Prometheus internal implementation is passing value for newQuery().
https://github.com/prometheus/prometheus/blob/v1.6.1/promql/engine.go#L343
https://github.com/prometheus/prometheus/blob/v1.6.1/promql/engine.go#L359

But, pass 0 step to query_range is not allowed.
https://github.com/prometheus/prometheus/blob/v1.6.1/web/api/v1/api.go#L229

@wtip
Copy link

wtip commented May 26, 2017

max_over_time(node_load5[30d]) < 0.5 this is another prometheus query that I am trying to display in a grafana table using just the query api.

@NicolaiPetri
Copy link

This is also an issue for me with grafana / prometheus table handling.
The query is: sum(service_ok) by (api,operation)
I'm trying nicely present this with only latest values, but no matter what I do it will always give me a range.
I can cheat by setting resolution to 1m and timespan to 1m and hiding time, but then my value column is not working since metrics with different amount of labels seem to overflow into wrong column (value column)

@fmmr
Copy link

fmmr commented Jul 4, 2017

+1

afaict this would be really helpfull for the pie-chart and other plugins as well.

pie-chart displays the last values of a time-series range - even if a metric does not have any values for the last/same timestamp as requested.

using query instead of query_range would solve the problem because prometheus would not return old value.

Also query is WAY more performant than query_range, especially for more complex queries.

@SuperQ
Copy link
Contributor

SuperQ commented Aug 23, 2017

👍

This would also be very useful for single stat panels.

@bergquist bergquist added this to the 4.6/5.0 milestone Sep 26, 2017
@bergquist bergquist modified the milestones: 4.6/5.0, 4.6 Oct 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment