Commit b69ebee0 by Marcus Efraimsson

mssql: fix precision for the time column in table/annotation query mode

Use the ConvertSqlTimeColumnToEpochMs function to convert any native
datetime data type or epoch time (millisecond precision).
Additional tests and update of existing due to timezone issues
running MSSQL on UTC and dev environment on non-utc.
Update stored procedures test to handle more parameters.
Update test dashboard.
parent b0076d4f
...@@ -119,15 +119,10 @@ func (e MssqlQueryEndpoint) transformToTable(query *tsdb.Query, rows *core.Rows, ...@@ -119,15 +119,10 @@ func (e MssqlQueryEndpoint) transformToTable(query *tsdb.Query, rows *core.Rows,
return err return err
} }
// convert column named time to unix timestamp to make // converts column named time to unix timestamp in milliseconds
// native datetime mssql types work in annotation queries // to make native mssql datetime types and epoch dates work in
if timeIndex != -1 { // annotation and table queries.
switch value := values[timeIndex].(type) { tsdb.ConvertSqlTimeColumnToEpochMs(values, timeIndex)
case time.Time:
values[timeIndex] = (float64(value.Unix()) * 1000) + float64(value.Nanosecond()/1e6) // in case someone is trying to map times beyond 2262 :D
}
}
table.Rows = append(table.Rows, values) table.Rows = append(table.Rows, values)
} }
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<pre class="gf-form-pre alert alert-info"><h6>Annotation Query Format</h6> <pre class="gf-form-pre alert alert-info"><h6>Annotation Query Format</h6>
An annotation is an event that is overlayed on top of graphs. The query can have up to three columns per row, the <b>time</b> column is mandatory. Annotation rendering is expensive so it is important to limit the number of rows returned. An annotation is an event that is overlayed on top of graphs. The query can have up to three columns per row, the <b>time</b> column is mandatory. Annotation rendering is expensive so it is important to limit the number of rows returned.
- column with alias: <b>time</b> for the annotation event time (in UTC). Use unix timestamp in seconds or any native date data type. - column with alias: <b>time</b> for the annotation event time. Use epoch time or any native date data type.
- column with alias: <b>text</b> for the annotation text. - column with alias: <b>text</b> for the annotation text.
- column with alias: <b>tags</b> for annotation tags. This is a comma separated string of tags e.g. 'tag1,tag2'. - column with alias: <b>tags</b> for annotation tags. This is a comma separated string of tags e.g. 'tag1,tag2'.
......
...@@ -128,7 +128,7 @@ export default class ResponseParser { ...@@ -128,7 +128,7 @@ export default class ResponseParser {
const row = table.rows[i]; const row = table.rows[i];
list.push({ list.push({
annotation: options.annotation, annotation: options.annotation,
time: row[timeColumnIndex], time: Math.floor(row[timeColumnIndex]),
text: row[textColumnIndex], text: row[textColumnIndex],
tags: row[tagsColumnIndex] ? row[tagsColumnIndex].trim().split(/\s*,\s*/) : [], tags: row[tagsColumnIndex] ? row[tagsColumnIndex].trim().split(/\s*,\s*/) : [],
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment