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
20bfe443
Commit
20bfe443
authored
Oct 19, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(prometheus): trim labelname lookup key
closes #6300
parent
b2d5b920
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
pkg/tsdb/prometheus/prometheus.go
+4
-2
pkg/tsdb/prometheus/prometheus_test.go
+1
-1
No files found.
pkg/tsdb/prometheus/prometheus.go
View file @
20bfe443
...
...
@@ -84,8 +84,10 @@ func formatLegend(metric pmodel.Metric, query *PrometheusQuery) string {
reg
,
_
:=
regexp
.
Compile
(
`\{\{\s*(.+?)\s*\}\}`
)
result
:=
reg
.
ReplaceAllFunc
([]
byte
(
query
.
LegendFormat
),
func
(
in
[]
byte
)
[]
byte
{
ind
:=
strings
.
Replace
(
strings
.
Replace
(
string
(
in
),
"{{"
,
""
,
1
),
"}}"
,
""
,
1
)
if
val
,
exists
:=
metric
[
pmodel
.
LabelName
(
ind
)];
exists
{
labelName
:=
strings
.
Replace
(
string
(
in
),
"{{"
,
""
,
1
)
labelName
=
strings
.
Replace
(
labelName
,
"}}"
,
""
,
1
)
labelName
=
strings
.
TrimSpace
(
labelName
)
if
val
,
exists
:=
metric
[
pmodel
.
LabelName
(
labelName
)];
exists
{
return
[]
byte
(
val
)
}
...
...
pkg/tsdb/prometheus/prometheus_test.go
View file @
20bfe443
...
...
@@ -17,7 +17,7 @@ func TestPrometheus(t *testing.T) {
}
query
:=
&
PrometheusQuery
{
LegendFormat
:
"legend {{app}} {{
device
}} {{broken}}"
,
LegendFormat
:
"legend {{app}} {{
device
}} {{broken}}"
,
}
So
(
formatLegend
(
metric
,
query
),
ShouldEqual
,
"legend backend mobile {{broken}}"
)
...
...
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