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
3d18c4d6
Unverified
Commit
3d18c4d6
authored
Aug 19, 2020
by
Ivana Huckova
Committed by
GitHub
Aug 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass scoped vars to create label (#27047)
parent
eafc132d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
5 deletions
+18
-5
public/app/plugins/datasource/prometheus/datasource.ts
+17
-4
public/app/plugins/datasource/prometheus/result_transformer.ts
+1
-1
No files found.
public/app/plugins/datasource/prometheus/datasource.ts
View file @
3d18c4d6
...
...
@@ -171,7 +171,13 @@ export class PrometheusDatasource extends DataSourceApi<PromQuery, PromOptions>
return
templateSrv
.
variableExists
(
target
.
expr
);
}
processResult
=
(
response
:
any
,
query
:
PromQueryRequest
,
target
:
PromQuery
,
responseListLength
:
number
)
=>
{
processResult
=
(
response
:
any
,
query
:
PromQueryRequest
,
target
:
PromQuery
,
responseListLength
:
number
,
scopedVars
?:
ScopedVars
)
=>
{
// Keeping original start/end for transformers
const
transformerOptions
=
{
format
:
target
.
format
,
...
...
@@ -181,6 +187,7 @@ export class PrometheusDatasource extends DataSourceApi<PromQuery, PromOptions>
end
:
query
.
end
,
query
:
query
.
expr
,
responseListLength
,
scopedVars
,
refId
:
target
.
refId
,
valueWithRefId
:
target
.
valueWithRefId
,
meta
:
{
...
...
@@ -256,7 +263,7 @@ export class PrometheusDatasource extends DataSourceApi<PromQuery, PromOptions>
return
this
.
exploreQuery
(
queries
,
activeTargets
,
end
);
}
return
this
.
panelsQuery
(
queries
,
activeTargets
,
end
,
options
.
requestId
);
return
this
.
panelsQuery
(
queries
,
activeTargets
,
end
,
options
.
requestId
,
options
.
scopedVars
);
}
private
exploreQuery
(
queries
:
PromQueryRequest
[],
activeTargets
:
PromQuery
[],
end
:
number
)
{
...
...
@@ -287,7 +294,13 @@ export class PrometheusDatasource extends DataSourceApi<PromQuery, PromOptions>
return
merge
(...
subQueries
);
}
private
panelsQuery
(
queries
:
PromQueryRequest
[],
activeTargets
:
PromQuery
[],
end
:
number
,
requestId
:
string
)
{
private
panelsQuery
(
queries
:
PromQueryRequest
[],
activeTargets
:
PromQuery
[],
end
:
number
,
requestId
:
string
,
scopedVars
:
ScopedVars
)
{
const
observables
:
Array
<
Observable
<
Array
<
TableModel
|
TimeSeries
>>>
=
queries
.
map
((
query
,
index
)
=>
{
const
target
=
activeTargets
[
index
];
...
...
@@ -298,7 +311,7 @@ export class PrometheusDatasource extends DataSourceApi<PromQuery, PromOptions>
return
observable
.
pipe
(
filter
((
response
:
any
)
=>
(
response
.
cancelled
?
false
:
true
)),
map
((
response
:
any
)
=>
{
const
data
=
this
.
processResult
(
response
,
query
,
target
,
queries
.
length
);
const
data
=
this
.
processResult
(
response
,
query
,
target
,
queries
.
length
,
scopedVars
);
return
data
;
})
);
...
...
public/app/plugins/datasource/prometheus/result_transformer.ts
View file @
3d18c4d6
...
...
@@ -160,7 +160,7 @@ export class ResultTransformer {
createLabelInfo
(
labels
:
{
[
key
:
string
]:
string
},
options
:
any
):
{
name
?:
string
;
labels
:
Labels
;
title
?:
string
}
{
if
(
options
?.
legendFormat
)
{
const
title
=
this
.
renderTemplate
(
this
.
templateSrv
.
replace
(
options
.
legendFormat
),
labels
);
const
title
=
this
.
renderTemplate
(
this
.
templateSrv
.
replace
(
options
.
legendFormat
,
options
?.
scopedVars
),
labels
);
return
{
name
:
title
,
title
,
labels
};
}
...
...
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