Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
af626466
Unverified
Commit
af626466
authored
Apr 10, 2018
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mysql: fix precision for time columns in time series query mode
parent
5c120c2c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
pkg/tsdb/mysql/mysql.go
+8
-6
pkg/tsdb/mysql/mysql_test.go
+0
-0
No files found.
pkg/tsdb/mysql/mysql.go
View file @
af626466
...
@@ -8,7 +8,6 @@ import (
...
@@ -8,7 +8,6 @@ import (
"math"
"math"
"reflect"
"reflect"
"strconv"
"strconv"
"time"
"github.com/go-sql-driver/mysql"
"github.com/go-sql-driver/mysql"
"github.com/go-xorm/core"
"github.com/go-xorm/core"
...
@@ -239,15 +238,18 @@ func (e MysqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
...
@@ -239,15 +238,18 @@ func (e MysqlQueryEndpoint) transformToTimeSeries(query *tsdb.Query, rows *core.
return
err
return
err
}
}
// converts column named time to unix timestamp in milliseconds to make
// native mysql datetime types and epoch dates work in
// annotation and table queries.
tsdb
.
ConvertSqlTimeColumnToEpochMs
(
values
,
timeIndex
)
switch
columnValue
:=
values
[
timeIndex
]
.
(
type
)
{
switch
columnValue
:=
values
[
timeIndex
]
.
(
type
)
{
case
int64
:
case
int64
:
timestamp
=
float64
(
columnValue
*
1000
)
timestamp
=
float64
(
columnValue
)
case
float64
:
case
float64
:
timestamp
=
columnValue
*
1000
timestamp
=
columnValue
case
time
.
Time
:
timestamp
=
float64
(
columnValue
.
UnixNano
()
/
1e6
)
default
:
default
:
return
fmt
.
Errorf
(
"Invalid type for column time, must be of type timestamp or unix timestamp, got: %T %v"
,
columnValue
,
columnValue
)
return
fmt
.
Errorf
(
"Invalid type for column time
/time_sec
, must be of type timestamp or unix timestamp, got: %T %v"
,
columnValue
,
columnValue
)
}
}
if
metricIndex
>=
0
{
if
metricIndex
>=
0
{
...
...
pkg/tsdb/mysql/mysql_test.go
View file @
af626466
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment