john
john

Reputation: 1125

Display Data in Graph Panel for some Custom Range for time in X-Axis

I am very new to Grafana, just started understanding since yesterday. I am using InfluxDB as a Datasource. I actually liked Grafana, but I could not able to achieve simple scenario.

I wanna show some data based on some "time" custom range in X-Axis. Although I could be able to select custom Date globally, but I wanna select time range (say, I wanna see graph of data between 5 Pm to 7 Pm of some column data for Jan 11, 2020), how can I achieve this in Graph Panel? I 've selected custom date using Date Picker as "Jan 11", but not understanding how to view data for some specific custom range in Graph Panel.

After searching, I found something like: $__from , $__to, but could not able to understand how to use it in Graph Panel. I mean here: https://grafana.com/docs/grafana/latest/reference/templating/

I will be glad if anyone could be able to look into my above issue. Thank you!

Upvotes: 0

Views: 702

Answers (1)

tomgalpin
tomgalpin

Reputation: 2093

Just make sure you have $timeFilter in your WHERE clause

https://grafana.com/docs/grafana/latest/reference/templating/#the-timefilter-or-timefilter-variable

For Example

SELECT SUM(*) from measurement.whatever WHERE $timeFilter

Say my time range on the Dashboard is "Last 7 Days"

The above would expand to

SELECT SUM(*) from measurement.whatever WHERE time >=now() -7d

Upvotes: 2

Related Questions