Reputation: 1000
I am using Druid as datasource for my grafana. I want to ignore the first and last data points from the druid query result(like trimming the edges). I am thinking of modifying the timestamp passed to druid query from the timepicker. But I cannot find a way to modify the timestamp choosen from the timepicker in grafana. Is there any other way to ignore the first and last data points? Sample query sent by grafana
"__time" >= TIME_PARSE('2022-02-13T07:32:46.055Z') AND "__time" <= TIME_PARSE('2022-02-13T10:32:46.055Z')
Upvotes: 1
Views: 1926
Reputation: 4275
If you are using any sql data source and want to pass value chosen from the date picker panel then inbuilt time series variable can be used
WHERE CAST(date_of_birth as date) between $__timeFrom() and $__timeTo()
And whatever you choose on top of the date picker ,picked values will be replaced here more info here https://grafana.com/docs/grafana/latest/datasources/mysql/
Upvotes: 0
Reputation: 181
In SQL you can use OFFSET 1
to skip the first row of the result, so this should allow you to remove the first data point. Unfortunately, that only solved half of your question.
You can use LIMIT N
so that only N rows are returned. In principle, if you know how many rows are in the result, you could use OFFSET 1 LIMIT <rowcount> - 2
to achieve what you want as long as rowcount > 2. But unless you have a fixed set of values per timeframe, it will likely prove hard to get that .
https://druid.apache.org/docs/latest/querying/sql.html#limit
Upvotes: 0
Reputation: 1305
I don't know about Druid specifically, but I can answer your question and tell you that it is possible to modify the time range selected by the time picker.
That is by using the built in variables $__from and $__to. Those give you begin and respectively end of the selected time range in UNIX milliseconds. You can then add/subtract milliseconds to/from those to modify the time range used in your query (e.g. in the WHERE clause).
Upvotes: 1