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
4b76c6d6
Commit
4b76c6d6
authored
Nov 17, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/omki2005/grafana
into omki2005-master
parents
153a9bf4
209f2deb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
4 deletions
+31
-4
public/app/plugins/datasource/influxdb/query_builder.js
+20
-4
public/app/plugins/datasource/influxdb/specs/query_builder_specs.ts
+11
-0
No files found.
public/app/plugins/datasource/influxdb/query_builder.js
View file @
4b76c6d6
...
...
@@ -42,13 +42,16 @@ function (_) {
p
.
buildExploreQuery
=
function
(
type
,
withKey
,
withMeasurementFilter
)
{
var
query
;
var
measurement
;
var
policy
;
if
(
type
===
'TAG_KEYS'
)
{
query
=
'SHOW TAG KEYS'
;
measurement
=
this
.
target
.
measurement
;
policy
=
this
.
target
.
policy
;
}
else
if
(
type
===
'TAG_VALUES'
)
{
query
=
'SHOW TAG VALUES'
;
measurement
=
this
.
target
.
measurement
;
policy
=
this
.
target
.
policy
;
}
else
if
(
type
===
'MEASUREMENTS'
)
{
query
=
'SHOW MEASUREMENTS'
;
if
(
withMeasurementFilter
)
...
...
@@ -56,11 +59,18 @@ function (_) {
query
+=
' WITH MEASUREMENT =~ /'
+
withMeasurementFilter
+
'/'
;
}
}
else
if
(
type
===
'FIELDS'
)
{
if
(
!
this
.
target
.
measurement
.
match
(
'^/.*/'
))
{
return
'SHOW FIELD KEYS FROM "'
+
this
.
target
.
measurement
+
'"'
;
}
else
{
return
'SHOW FIELD KEYS FROM '
+
this
.
target
.
measurement
;
measurement
=
this
.
target
.
measurement
;
policy
=
this
.
target
.
policy
;
if
(
!
measurement
.
match
(
'^/.*/'
))
{
measurement
=
'"'
+
measurement
+
'"'
;
if
(
policy
)
{
if
(
!
policy
.
match
(
'^/.*/'
))
{
policy
=
'"'
+
policy
+
'"'
;
}
measurement
=
policy
+
'.'
+
measurement
;
}
}
return
'SHOW FIELD KEYS FROM '
+
measurement
;
}
else
if
(
type
===
'RETENTION POLICIES'
)
{
query
=
'SHOW RETENTION POLICIES on "'
+
this
.
database
+
'"'
;
return
query
;
...
...
@@ -70,6 +80,12 @@ function (_) {
if
(
!
measurement
.
match
(
'^/.*/'
)
&&
!
measurement
.
match
(
/^merge
\(
.*
\)
/
))
{
measurement
=
'"'
+
measurement
+
'"'
;
}
if
(
policy
)
{
if
(
!
policy
.
match
(
'^/.*/'
)
&&
!
policy
.
match
(
/^merge
\(
.*
\)
/
))
{
policy
=
'"'
+
policy
+
'"'
;
}
measurement
=
policy
+
'.'
+
measurement
;
}
query
+=
' FROM '
+
measurement
;
}
...
...
public/app/plugins/datasource/influxdb/specs/query_builder_specs.ts
View file @
4b76c6d6
...
...
@@ -73,6 +73,17 @@ describe('InfluxQueryBuilder', function() {
expect
(
query
).
to
.
be
(
'SHOW TAG VALUES FROM "cpu" WITH KEY = "app" WHERE "host" =
\'
server1
\'
'
);
});
it
(
'should select from policy correctly if policy is specified'
,
function
()
{
var
builder
=
new
InfluxQueryBuilder
({
measurement
:
'cpu'
,
policy
:
'one_week'
,
tags
:
[{
key
:
'app'
,
value
:
'email'
},
{
key
:
'host'
,
value
:
'server1'
}]
});
var
query
=
builder
.
buildExploreQuery
(
'TAG_VALUES'
,
'app'
);
expect
(
query
).
to
.
be
(
'SHOW TAG VALUES FROM "one_week"."cpu" WITH KEY = "app" WHERE "host" =
\'
server1
\'
'
);
});
it
(
'should switch to regex operator in tag condition'
,
function
()
{
var
builder
=
new
InfluxQueryBuilder
({
measurement
:
'cpu'
,
...
...
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