grafana / timestream-datasource

Amazon Timestream in Grafana
https://grafana.com/grafana/plugins/grafana-timestream-datasource
Apache License 2.0
24 stars 19 forks source link

Is `$__timeFilter` not supported in variables based on Timestream query? #66

Closed RSATom closed 3 years ago

RSATom commented 3 years ago

I've tried to use very basic SQL and it doesn't return any value:

SELECT session_id
FROM "Events"."PluginEvents"
WHERE $timeFilter

Is it really missing or I just do something wrong?

tiratatp commented 3 years ago

Lol I was about to open a new issue for this.

I added a debugging message in Go code and found that $__timeFilter was replaced to time BETWEEN from_milliseconds(0) AND from_milliseconds(0)

So it seems like timeRange that was passed from the front end was wrong,

t=2021-02-15T21:32:06+0000 lvl=info msg=GetQueryModel: logger=plugins.backend pluginId=grafana-timestream-datasource query="map[Interval:1e+09 JSON:map[database: datasourceId:1 measure: rawQuery:select distinct measure_name from \"A3_cross_tier_db_cmk\".\"static_data_table\" where $__timeFilter refId:GetStrings table:] MaxDataPoints:100 QueryType: RefID:GetStrings TimeRange:map[From:1970-01-01T00:00:00Z To:1970-01-01T00:00:00Z]]" json="map[database: datasourceId:1 measure: rawQuery:select distinct measure_name from \"A3_cross_tier_db_cmk\".\"static_data_table\" where $__timeFilter refId:GetStrings table:]" model.Interval.Milliseconds()=0.000

t=2021-02-15T21:32:06+0000 lvl=info msg=GetQueryModel: logger=plugins.backend pluginId=grafana-timestream-datasource model="map[rawQuery:select distinct measure_name from \"A3_cross_tier_db_cmk\".\"static_data_table\" where $__timeFilter]" model.Interval=1000000000.000 model.MaxDataPoints=100.000 model.TimeRange="map[From:1970-01-01T00:00:00Z To:1970-01-01T00:00:00Z]"

t=2021-02-15T21:32:06+0000 lvl=info msg=Interpolate: logger=plugins.backend pluginId=grafana-timestream-datasource query="map[rawQuery:select distinct measure_name from \"A3_cross_tier_db_cmk\".\"static_data_table\" where $__timeFilter]" timeRange="map[From:1970-01-01T00:00:00Z To:1970-01-01T00:00:00Z]" timeRange.From=1970-01-01T00:00:00Z timeRange.To=1970-01-01T00:00:00Z

I'm not sure the frontend set the value for timeRange

RSATom commented 3 years ago

@tiratatp I can confirm #67 fixed issue with $__timeFilter