gbrian / grafana-simple-sql-datasource

Grafana SQL datasource
MIT License
62 stars 20 forks source link

"invalid date" when testing even with the sample query provided #19

Closed sawo1337 closed 6 years ago

sawo1337 commented 6 years ago

Latest version of the data source installed, everything works as expected, apart from being unable to get the dates to work. I have copied the sample SQL query provided in the documentation, but even that returns "Invalid date" on the graph and the X axis is not drawing data properly. Here is the query used:

DECLARE @data TABLE(value decimal, dt DateTime);
DECLARE @stopDT DateTime = '$to';
DECLARE @startDT DateTime = '$from';
WHILE(@startDT < @stopDT)
BEGIN
INSERT INTO @data VALUES(RAND(),@startDT);
SET @startDT = DATEADD(minute, 1, @startDT)
END
select 'metric' as metric, * from @data

This is used as timeseries, here is the JSON response i get:

response:Array[1]
0:Object
target:"metric"
datapoints:Array[4]
0:Array[1,metric]
1:Array[1,metric]
2:Array[1,metric]
3:Array[0,metric]

I noticed that I don't get a date in the response, is this normal?

Here is a screenshot of my graph: https://i.imgur.com/4n5NSjo.png image

sawo1337 commented 6 years ago

figured out the issue - the sample query provided in the documentation had metric selected first, while you actually need time, value, metric - in that precise order.