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
03aed21d
Unverified
Commit
03aed21d
authored
Aug 14, 2018
by
Marcus Efraimsson
Committed by
GitHub
Aug 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12598 from kichristensen/TimeRangeVariables
Support timeFilter in query templating for InfluxDB
parents
766d0bef
8c52e2cd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
public/app/plugins/datasource/influxdb/datasource.ts
+5
-0
public/app/plugins/datasource/influxdb/specs/datasource.jest.ts
+53
-0
No files found.
public/app/plugins/datasource/influxdb/datasource.ts
View file @
03aed21d
...
...
@@ -187,6 +187,11 @@ export default class InfluxDatasource {
return
this
.
$q
.
when
({
results
:
[]
});
}
if
(
options
&&
options
.
range
)
{
var
timeFilter
=
this
.
getTimeFilter
({
rangeRaw
:
options
.
range
});
query
=
query
.
replace
(
'$timeFilter'
,
timeFilter
);
}
return
this
.
_influxRequest
(
'GET'
,
'/query'
,
{
q
:
query
,
epoch
:
'ms'
},
options
);
}
...
...
public/app/plugins/datasource/influxdb/specs/datasource.jest.ts
0 → 100644
View file @
03aed21d
import
InfluxDatasource
from
'../datasource'
;
import
$q
from
'q'
;
import
{
TemplateSrvStub
}
from
'test/specs/helpers'
;
describe
(
'InfluxDataSource'
,
()
=>
{
let
ctx
:
any
=
{
backendSrv
:
{},
$q
:
$q
,
templateSrv
:
new
TemplateSrvStub
(),
instanceSettings
:
{
url
:
'url'
,
name
:
'influxDb'
,
jsonData
:
{}
},
};
beforeEach
(
function
()
{
ctx
.
instanceSettings
.
url
=
'/api/datasources/proxy/1'
;
ctx
.
ds
=
new
InfluxDatasource
(
ctx
.
instanceSettings
,
ctx
.
$q
,
ctx
.
backendSrv
,
ctx
.
templateSrv
);
});
describe
(
'When issuing metricFindQuery'
,
()
=>
{
let
query
=
'SELECT max(value) FROM measurement WHERE $timeFilter'
;
let
queryOptions
:
any
=
{
range
:
{
from
:
'2018-01-01T00:00:00Z'
,
to
:
'2018-01-02T00:00:00Z'
,
},
};
let
requestQuery
;
beforeEach
(
async
()
=>
{
ctx
.
backendSrv
.
datasourceRequest
=
function
(
req
)
{
requestQuery
=
req
.
params
.
q
;
return
ctx
.
$q
.
when
({
results
:
[
{
series
:
[
{
name
:
'measurement'
,
columns
:
[
'max'
],
values
:
[[
1
]],
},
],
},
],
});
};
await
ctx
.
ds
.
metricFindQuery
(
query
,
queryOptions
).
then
(
function
(
_
)
{});
});
it
(
'should replace $timefilter'
,
()
=>
{
expect
(
requestQuery
).
toMatch
(
'time >= 1514764800000ms and time <= 1514851200000ms'
);
});
});
});
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