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
56bef637
Commit
56bef637
authored
Mar 01, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(templating): fixes for influxdb template variable formating, #2918
parent
d1bac6cd
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
8 deletions
+13
-8
public/app/plugins/datasource/influxdb/datasource.ts
+1
-1
public/app/plugins/datasource/influxdb/influx_query.ts
+11
-7
public/app/plugins/datasource/influxdb/query_ctrl.ts
+1
-0
No files found.
public/app/plugins/datasource/influxdb/datasource.ts
View file @
56bef637
...
...
@@ -35,7 +35,7 @@ export function InfluxDatasource(instanceSettings, $q, backendSrv, templateSrv)
// build query
var
queryModel
=
new
InfluxQuery
(
target
,
templateSrv
,
options
.
scopedVars
);
var
query
=
queryModel
.
render
();
var
query
=
queryModel
.
render
(
true
);
query
=
query
.
replace
(
/
\$
interval/g
,
(
target
.
interval
||
options
.
interval
));
return
query
;
...
...
public/app/plugins/datasource/influxdb/influx_query.ts
View file @
56bef637
...
...
@@ -11,7 +11,7 @@ export default class InfluxQuery {
templateSrv
:
any
;
scopedVars
:
any
;
constructor
(
target
,
templateSrv
,
scopedVars
)
{
constructor
(
target
,
templateSrv
?,
scopedVars
?
)
{
this
.
target
=
target
;
this
.
templateSrv
=
templateSrv
;
this
.
scopedVars
=
scopedVars
;
...
...
@@ -130,7 +130,7 @@ export default class InfluxQuery {
this
.
updatePersistedParts
();
}
private
renderTagCondition
(
tag
,
index
)
{
private
renderTagCondition
(
tag
,
index
,
interpolate
)
{
var
str
=
""
;
var
operator
=
tag
.
operator
;
var
value
=
tag
.
value
;
...
...
@@ -148,9 +148,11 @@ export default class InfluxQuery {
// quote value unless regex
if
(
operator
!==
'=~'
&&
operator
!==
'!~'
)
{
if
(
interpolate
)
{
value
=
this
.
templateSrv
.
replace
(
value
,
this
.
scopedVars
);
}
value
=
"'"
+
value
.
replace
(
'
\
\'
, '
\\\\
') + "'
";
} else {
} else
if (interpolate)
{
value = this.templateSrv.replace(value, this.scopedVars, 'regex');
}
...
...
@@ -174,12 +176,16 @@ export default class InfluxQuery {
return policy + measurement;
}
render() {
render(
interpolate?
) {
var target = this.target;
if (target.rawQuery) {
if (interpolate) {
return this.templateSrv.replace(target.query, this.scopedVars, 'regex');
} else {
return target.query;
}
}
if (!target.measurement) {
throw {message: "
Metric
measurement
is
missing
"};
...
...
@@ -203,7 +209,7 @@ export default class InfluxQuery {
query += ' FROM ' + this.getMeasurementAndPolicy() + ' WHERE ';
var conditions = _.map(target.tags, (tag, index) => {
return this.renderTagCondition(tag, index);
return this.renderTagCondition(tag, index
, interpolate
);
});
query += conditions.join(' ');
...
...
@@ -227,8 +233,6 @@ export default class InfluxQuery {
query += ' fill(' + target.fill + ')';
}
target.query = query;
return query;
}
}
public/app/plugins/datasource/influxdb/query_ctrl.ts
View file @
56bef637
...
...
@@ -154,6 +154,7 @@ export class InfluxQueryCtrl extends QueryCtrl {
}
toggleEditorMode
()
{
this
.
target
.
query
=
this
.
queryModel
.
render
(
false
);
this
.
target
.
rawQuery
=
!
this
.
target
.
rawQuery
;
}
...
...
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