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
b86a42ff
Commit
b86a42ff
authored
Dec 09, 2017
by
Sven Klemm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pass tsdbQuery to transformToTimeSeries and transformToTable to get
access to selected frontend timerange
parent
b6df91d5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
10 deletions
+10
-10
pkg/tsdb/mysql/mysql.go
+2
-2
pkg/tsdb/postgres/postgres.go
+2
-2
pkg/tsdb/sql_engine.go
+6
-6
No files found.
pkg/tsdb/mysql/mysql.go
View file @
b86a42ff
...
...
@@ -56,7 +56,7 @@ func (e *MysqlQueryEndpoint) Query(ctx context.Context, dsInfo *models.DataSourc
return
e
.
sqlEngine
.
Query
(
ctx
,
dsInfo
,
tsdbQuery
,
e
.
transformToTimeSeries
,
e
.
transformToTable
)
}
func
(
e
MysqlQueryEndpoint
)
transformToTable
(
query
*
tsdb
.
Query
,
rows
*
core
.
Rows
,
result
*
tsdb
.
QueryResult
)
error
{
func
(
e
MysqlQueryEndpoint
)
transformToTable
(
query
*
tsdb
.
Query
,
rows
*
core
.
Rows
,
result
*
tsdb
.
QueryResult
,
tsdbQuery
*
tsdb
.
TsdbQuery
)
error
{
columnNames
,
err
:=
rows
.
Columns
()
columnCount
:=
len
(
columnNames
)
...
...
@@ -163,7 +163,7 @@ func (e MysqlQueryEndpoint) getTypedRowData(types []*sql.ColumnType, rows *core.
return
values
,
nil
}
func
(
e
MysqlQueryEndpoint
)
transformToTimeSeries
(
query
*
tsdb
.
Query
,
rows
*
core
.
Rows
,
result
*
tsdb
.
QueryResult
)
error
{
func
(
e
MysqlQueryEndpoint
)
transformToTimeSeries
(
query
*
tsdb
.
Query
,
rows
*
core
.
Rows
,
result
*
tsdb
.
QueryResult
,
tsdbQuery
*
tsdb
.
TsdbQuery
)
error
{
pointsBySeries
:=
make
(
map
[
string
]
*
tsdb
.
TimeSeries
)
seriesByQueryOrder
:=
list
.
New
()
columnNames
,
err
:=
rows
.
Columns
()
...
...
pkg/tsdb/postgres/postgres.go
View file @
b86a42ff
...
...
@@ -60,7 +60,7 @@ func (e *PostgresQueryEndpoint) Query(ctx context.Context, dsInfo *models.DataSo
return
e
.
sqlEngine
.
Query
(
ctx
,
dsInfo
,
tsdbQuery
,
e
.
transformToTimeSeries
,
e
.
transformToTable
)
}
func
(
e
PostgresQueryEndpoint
)
transformToTable
(
query
*
tsdb
.
Query
,
rows
*
core
.
Rows
,
result
*
tsdb
.
QueryResult
)
error
{
func
(
e
PostgresQueryEndpoint
)
transformToTable
(
query
*
tsdb
.
Query
,
rows
*
core
.
Rows
,
result
*
tsdb
.
QueryResult
,
tsdbQuery
*
tsdb
.
TsdbQuery
)
error
{
columnNames
,
err
:=
rows
.
Columns
()
if
err
!=
nil
{
...
...
@@ -157,7 +157,7 @@ func (e PostgresQueryEndpoint) getTypedRowData(rows *core.Rows) (tsdb.RowValues,
return
values
,
nil
}
func
(
e
PostgresQueryEndpoint
)
transformToTimeSeries
(
query
*
tsdb
.
Query
,
rows
*
core
.
Rows
,
result
*
tsdb
.
QueryResult
)
error
{
func
(
e
PostgresQueryEndpoint
)
transformToTimeSeries
(
query
*
tsdb
.
Query
,
rows
*
core
.
Rows
,
result
*
tsdb
.
QueryResult
,
tsdbQuery
*
tsdb
.
TsdbQuery
)
error
{
pointsBySeries
:=
make
(
map
[
string
]
*
tsdb
.
TimeSeries
)
seriesByQueryOrder
:=
list
.
New
()
...
...
pkg/tsdb/sql_engine.go
View file @
b86a42ff
...
...
@@ -17,8 +17,8 @@ type SqlEngine interface {
ctx
context
.
Context
,
ds
*
models
.
DataSource
,
query
*
TsdbQuery
,
transformToTimeSeries
func
(
query
*
Query
,
rows
*
core
.
Rows
,
result
*
QueryResult
)
error
,
transformToTable
func
(
query
*
Query
,
rows
*
core
.
Rows
,
result
*
QueryResult
)
error
,
transformToTimeSeries
func
(
query
*
Query
,
rows
*
core
.
Rows
,
result
*
QueryResult
,
tsdbQuery
*
TsdbQuery
)
error
,
transformToTable
func
(
query
*
Query
,
rows
*
core
.
Rows
,
result
*
QueryResult
,
tsdbQuery
*
TsdbQuery
)
error
,
)
(
*
Response
,
error
)
}
...
...
@@ -77,8 +77,8 @@ func (e *DefaultSqlEngine) Query(
ctx
context
.
Context
,
dsInfo
*
models
.
DataSource
,
tsdbQuery
*
TsdbQuery
,
transformToTimeSeries
func
(
query
*
Query
,
rows
*
core
.
Rows
,
result
*
QueryResult
)
error
,
transformToTable
func
(
query
*
Query
,
rows
*
core
.
Rows
,
result
*
QueryResult
)
error
,
transformToTimeSeries
func
(
query
*
Query
,
rows
*
core
.
Rows
,
result
*
QueryResult
,
tsdbQuery
*
TsdbQuery
)
error
,
transformToTable
func
(
query
*
Query
,
rows
*
core
.
Rows
,
result
*
QueryResult
,
tsdbQuery
*
TsdbQuery
)
error
,
)
(
*
Response
,
error
)
{
result
:=
&
Response
{
Results
:
make
(
map
[
string
]
*
QueryResult
),
...
...
@@ -117,13 +117,13 @@ func (e *DefaultSqlEngine) Query(
switch
format
{
case
"time_series"
:
err
:=
transformToTimeSeries
(
query
,
rows
,
queryResult
)
err
:=
transformToTimeSeries
(
query
,
rows
,
queryResult
,
tsdbQuery
)
if
err
!=
nil
{
queryResult
.
Error
=
err
continue
}
case
"table"
:
err
:=
transformToTable
(
query
,
rows
,
queryResult
)
err
:=
transformToTable
(
query
,
rows
,
queryResult
,
tsdbQuery
)
if
err
!=
nil
{
queryResult
.
Error
=
err
continue
...
...
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