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
ce155a1d
Commit
ce155a1d
authored
Jul 08, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2301 from tmonk42/influxdb_quoting
add double quotes around tags
parents
66ba19b7
56c332a3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
+12
-12
public/app/plugins/datasource/influxdb/queryBuilder.js
+3
-3
public/test/specs/influx09-querybuilder-specs.js
+9
-9
No files found.
public/app/plugins/datasource/influxdb/queryBuilder.js
View file @
ce155a1d
...
...
@@ -15,9 +15,9 @@ function (_) {
}
if
(
tag
.
value
&&
tag
.
value
[
0
]
===
'/'
&&
tag
.
value
[
tag
.
value
.
length
-
1
]
===
'/'
)
{
return
str
+
tag
.
key
+
' =~ '
+
tag
.
value
;
return
str
+
'"'
+
tag
.
key
+
'"'
+
' =~ '
+
tag
.
value
;
}
return
str
+
tag
.
key
+
" = '"
+
tag
.
value
+
"'"
;
return
str
+
'"'
+
tag
.
key
+
'"'
+
" = '"
+
tag
.
value
+
"'"
;
}
var
p
=
InfluxQueryBuilder
.
prototype
;
...
...
@@ -92,7 +92,7 @@ function (_) {
query
+=
' GROUP BY time($interval)'
;
if
(
target
.
groupByTags
&&
target
.
groupByTags
.
length
>
0
)
{
query
+=
',
'
+
target
.
groupByTags
.
join
()
;
query
+=
',
"'
+
target
.
groupByTags
.
join
(
'", "'
)
+
'"'
;
}
if
(
target
.
fill
)
{
...
...
public/test/specs/influx09-querybuilder-specs.js
View file @
ce155a1d
...
...
@@ -27,14 +27,14 @@ define([
var
query
=
builder
.
build
();
it
(
'should generate correct query'
,
function
()
{
expect
(
query
).
to
.
be
(
'SELECT mean(value) FROM "cpu" WHERE
hostname
=
\'
server1
\'
AND $timeFilter'
expect
(
query
).
to
.
be
(
'SELECT mean(value) FROM "cpu" WHERE
"hostname"
=
\'
server1
\'
AND $timeFilter'
+
' GROUP BY time($interval) ORDER BY asc'
);
});
it
(
'should switch regex operator with tag value is regex'
,
function
()
{
var
builder
=
new
InfluxQueryBuilder
({
measurement
:
'cpu'
,
tags
:
[{
key
:
'app'
,
value
:
'/e.*/'
}]});
var
query
=
builder
.
build
();
expect
(
query
).
to
.
be
(
'SELECT mean(value) FROM "cpu" WHERE
app
=~ /e.*/ AND $timeFilter GROUP BY time($interval) ORDER BY asc'
);
expect
(
query
).
to
.
be
(
'SELECT mean(value) FROM "cpu" WHERE
"app"
=~ /e.*/ AND $timeFilter GROUP BY time($interval) ORDER BY asc'
);
});
});
...
...
@@ -47,7 +47,7 @@ define([
var
query
=
builder
.
build
();
it
(
'should generate correct query'
,
function
()
{
expect
(
query
).
to
.
be
(
'SELECT mean(value) FROM "cpu" WHERE
hostname =
\'
server1
\'
AND app
=
\'
email
\'
AND '
+
expect
(
query
).
to
.
be
(
'SELECT mean(value) FROM "cpu" WHERE
"hostname" =
\'
server1
\'
AND "app"
=
\'
email
\'
AND '
+
'$timeFilter GROUP BY time($interval) ORDER BY asc'
);
});
});
...
...
@@ -61,7 +61,7 @@ define([
var
query
=
builder
.
build
();
it
(
'should generate correct query'
,
function
()
{
expect
(
query
).
to
.
be
(
'SELECT mean(value) FROM "cpu" WHERE
hostname =
\'
server1
\'
OR hostname
=
\'
server2
\'
AND '
+
expect
(
query
).
to
.
be
(
'SELECT mean(value) FROM "cpu" WHERE
"hostname" =
\'
server1
\'
OR "hostname"
=
\'
server2
\'
AND '
+
'$timeFilter GROUP BY time($interval) ORDER BY asc'
);
});
});
...
...
@@ -76,7 +76,7 @@ define([
var
query
=
builder
.
build
();
expect
(
query
).
to
.
be
(
'SELECT mean(value) FROM "cpu" WHERE $timeFilter '
+
'GROUP BY time($interval),
host
ORDER BY asc'
);
'GROUP BY time($interval),
"host"
ORDER BY asc'
);
});
});
...
...
@@ -97,7 +97,7 @@ define([
it
(
'should have where condition in tag keys query with tags'
,
function
()
{
var
builder
=
new
InfluxQueryBuilder
({
measurement
:
''
,
tags
:
[{
key
:
'host'
,
value
:
'se1'
}]
});
var
query
=
builder
.
buildExploreQuery
(
'TAG_KEYS'
);
expect
(
query
).
to
.
be
(
"SHOW TAG KEYS WHERE
host
= 'se1'"
);
expect
(
query
).
to
.
be
(
"SHOW TAG KEYS WHERE
\"
host
\"
= 'se1'"
);
});
it
(
'should have no conditions in measurement query for query with no tags'
,
function
()
{
...
...
@@ -109,7 +109,7 @@ define([
it
(
'should have where condition in measurement query for query with tags'
,
function
()
{
var
builder
=
new
InfluxQueryBuilder
({
measurement
:
''
,
tags
:
[{
key
:
'app'
,
value
:
'email'
}]});
var
query
=
builder
.
buildExploreQuery
(
'MEASUREMENTS'
);
expect
(
query
).
to
.
be
(
"SHOW MEASUREMENTS WHERE
app
= 'email'"
);
expect
(
query
).
to
.
be
(
"SHOW MEASUREMENTS WHERE
\"
app
\"
= 'email'"
);
});
it
(
'should have where tag name IN filter in tag values query for query with one tag'
,
function
()
{
...
...
@@ -121,13 +121,13 @@ define([
it
(
'should have measurement tag condition and tag name IN filter in tag values query'
,
function
()
{
var
builder
=
new
InfluxQueryBuilder
({
measurement
:
'cpu'
,
tags
:
[{
key
:
'app'
,
value
:
'email'
},
{
key
:
'host'
,
value
:
'server1'
}]});
var
query
=
builder
.
buildExploreQuery
(
'TAG_VALUES'
,
'app'
);
expect
(
query
).
to
.
be
(
'SHOW TAG VALUES FROM "cpu" WITH KEY = "app" WHERE
host
=
\'
server1
\'
'
);
expect
(
query
).
to
.
be
(
'SHOW TAG VALUES FROM "cpu" WITH KEY = "app" WHERE
"host"
=
\'
server1
\'
'
);
});
it
(
'should switch to regex operator in tag condition'
,
function
()
{
var
builder
=
new
InfluxQueryBuilder
({
measurement
:
'cpu'
,
tags
:
[{
key
:
'host'
,
value
:
'/server.*/'
}]});
var
query
=
builder
.
buildExploreQuery
(
'TAG_VALUES'
,
'app'
);
expect
(
query
).
to
.
be
(
'SHOW TAG VALUES FROM "cpu" WITH KEY = "app" WHERE
host
=~ /server.*/'
);
expect
(
query
).
to
.
be
(
'SHOW TAG VALUES FROM "cpu" WITH KEY = "app" WHERE
"host"
=~ /server.*/'
);
});
});
...
...
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