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
6fd0d5e2
Commit
6fd0d5e2
authored
Feb 28, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4178 from mtanda/prometheus_template_label
(prometheus) fix label_values() templating
parents
b9e0fcdf
3125177e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
public/app/plugins/datasource/prometheus/metric_find_query.js
+3
-3
public/app/plugins/datasource/prometheus/specs/metric_find_query_specs.ts
+16
-0
No files found.
public/app/plugins/datasource/prometheus/metric_find_query.js
View file @
6fd0d5e2
...
...
@@ -11,16 +11,16 @@ function (_, moment) {
}
PrometheusMetricFindQuery
.
prototype
.
process
=
function
()
{
var
label_values_regex
=
/^label_values
\((
[^
,
]
+
)(?:
,
\s
*
(
.+
))?
\)
$/
;
var
label_values_regex
=
/^label_values
\((
?:(
.+
)
,
\s
*
)?([
a-zA-Z_
][
a-zA-Z0-9_
]
+
)
\)
$/
;
var
metric_names_regex
=
/^metrics
\((
.+
)\)
$/
;
var
query_result_regex
=
/^query_result
\((
.+
)\)
$/
;
var
label_values_query
=
this
.
query
.
match
(
label_values_regex
);
if
(
label_values_query
)
{
if
(
label_values_query
[
2
])
{
if
(
label_values_query
[
1
])
{
return
this
.
labelValuesQuery
(
label_values_query
[
2
],
label_values_query
[
1
]);
}
else
{
return
this
.
labelValuesQuery
(
label_values_query
[
1
],
null
);
return
this
.
labelValuesQuery
(
label_values_query
[
2
],
null
);
}
}
...
...
public/app/plugins/datasource/prometheus/specs/metric_find_query_specs.ts
View file @
6fd0d5e2
...
...
@@ -48,6 +48,22 @@ describe('PrometheusMetricFindQuery', function() {
ctx
.
$rootScope
.
$apply
();
expect
(
results
.
length
).
to
.
be
(
3
);
});
it
(
'label_values(metric{label1="foo", label2="bar", label3="baz"}, resource) should generate series query'
,
function
()
{
response
=
{
status
:
"success"
,
data
:
[
{
__name__
:
"metric"
,
resource
:
"value1"
},
{
__name__
:
"metric"
,
resource
:
"value2"
},
{
__name__
:
"metric"
,
resource
:
"value3"
}
]
};
ctx
.
$httpBackend
.
expect
(
'GET'
,
'proxied/api/v1/series?match[]=metric'
).
respond
(
response
);
var
pm
=
new
PrometheusMetricFindQuery
(
ctx
.
ds
,
'label_values(metric, resource)'
);
pm
.
process
().
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$httpBackend
.
flush
();
ctx
.
$rootScope
.
$apply
();
expect
(
results
.
length
).
to
.
be
(
3
);
});
it
(
'metrics(metric.*) should generate metric name query'
,
function
()
{
response
=
{
status
:
"success"
,
...
...
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