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
4fdfee73
Commit
4fdfee73
authored
Nov 14, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(influxdb): add support for regex measurments
closes #6560
parent
a87fd11f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
pkg/tsdb/influxdb/query.go
+10
-2
pkg/tsdb/influxdb/query_test.go
+12
-0
No files found.
pkg/tsdb/influxdb/query.go
View file @
4fdfee73
...
...
@@ -11,7 +11,8 @@ import (
)
var
(
regexpOperatorPattern
*
regexp
.
Regexp
=
regexp
.
MustCompile
(
`^\/.*\/$`
)
regexpOperatorPattern
*
regexp
.
Regexp
=
regexp
.
MustCompile
(
`^\/.*\/$`
)
regexpMeasurementPattern
*
regexp
.
Regexp
=
regexp
.
MustCompile
(
`^\/.*\/$`
)
)
func
(
query
*
Query
)
Build
(
queryContext
*
tsdb
.
QueryContext
)
(
string
,
error
)
{
...
...
@@ -108,7 +109,14 @@ func (query *Query) renderMeasurement() string {
}
else
{
policy
=
`"`
+
query
.
Policy
+
`".`
}
return
fmt
.
Sprintf
(
` FROM %s"%s"`
,
policy
,
query
.
Measurement
)
measurement
:=
query
.
Measurement
if
!
regexpMeasurementPattern
.
Match
([]
byte
(
measurement
))
{
measurement
=
fmt
.
Sprintf
(
`"%s"`
,
measurement
)
}
return
fmt
.
Sprintf
(
` FROM %s%s`
,
policy
,
measurement
)
}
func
(
query
*
Query
)
renderWhereClause
()
string
{
...
...
pkg/tsdb/influxdb/query_test.go
View file @
4fdfee73
...
...
@@ -120,5 +120,17 @@ func TestInfluxdbQueryBuilder(t *testing.T) {
So
(
strings
.
Join
(
query
.
renderTags
(),
""
),
ShouldEqual
,
`"key" = 'value'`
)
})
Convey
(
"can render regular measurement"
,
func
()
{
query
:=
&
Query
{
Measurement
:
`apa`
,
Policy
:
"policy"
}
So
(
query
.
renderMeasurement
(),
ShouldEqual
,
` FROM "policy"."apa"`
)
})
Convey
(
"can render regexp measurement"
,
func
()
{
query
:=
&
Query
{
Measurement
:
`/apa/`
,
Policy
:
"policy"
}
So
(
query
.
renderMeasurement
(),
ShouldEqual
,
` FROM "policy"./apa/`
)
})
})
}
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