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
c9ee0542
Commit
c9ee0542
authored
Sep 24, 2018
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: move getLabels from query_ctrl to datasource
so can reuse for annotation query ctrl.
parent
e101bcdb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
17 deletions
+22
-17
public/app/plugins/datasource/stackdriver/datasource.ts
+18
-1
public/app/plugins/datasource/stackdriver/query_ctrl.ts
+3
-15
public/app/plugins/datasource/stackdriver/specs/query_ctrl.test.ts
+1
-1
No files found.
public/app/plugins/datasource/stackdriver/datasource.ts
View file @
c9ee0542
...
...
@@ -5,7 +5,7 @@ export default class StackdriverDatasource {
baseUrl
:
string
;
projectName
:
string
;
constructor
(
instanceSettings
,
private
backendSrv
,
private
templateSrv
)
{
constructor
(
instanceSettings
,
private
backendSrv
,
private
templateSrv
,
private
timeSrv
)
{
this
.
baseUrl
=
`/stackdriver/`
;
this
.
url
=
instanceSettings
.
url
;
this
.
doRequest
=
this
.
doRequest
;
...
...
@@ -54,6 +54,23 @@ export default class StackdriverDatasource {
return
data
;
}
async
getLabels
(
metricType
,
refId
)
{
return
await
this
.
getTimeSeries
({
targets
:
[
{
refId
:
refId
,
datasourceId
:
this
.
id
,
metricType
:
this
.
templateSrv
.
replace
(
metricType
),
aggregation
:
{
crossSeriesReducer
:
'REDUCE_NONE'
,
},
view
:
'HEADERS'
,
},
],
range
:
this
.
timeSrv
.
timeRange
(),
});
}
interpolateGroupBys
(
groupBys
:
string
[],
scopedVars
):
string
[]
{
let
interpolatedGroupBys
=
[];
(
groupBys
||
[]).
forEach
(
gb
=>
{
...
...
public/app/plugins/datasource/stackdriver/query_ctrl.ts
View file @
c9ee0542
...
...
@@ -62,7 +62,7 @@ export class StackdriverQueryCtrl extends QueryCtrl {
filterSegments
:
any
;
/** @ngInject */
constructor
(
$scope
,
$injector
,
private
uiSegmentSrv
,
private
t
imeSrv
,
private
t
emplateSrv
)
{
constructor
(
$scope
,
$injector
,
private
uiSegmentSrv
,
private
templateSrv
)
{
super
(
$scope
,
$injector
);
_
.
defaultsDeep
(
this
.
target
,
this
.
defaults
);
...
...
@@ -130,25 +130,13 @@ export class StackdriverQueryCtrl extends QueryCtrl {
async
getLabels
()
{
this
.
loadLabelsPromise
=
new
Promise
(
async
resolve
=>
{
try
{
const
data
=
await
this
.
datasource
.
getTimeSeries
({
targets
:
[
{
refId
:
this
.
target
.
refId
,
datasourceId
:
this
.
datasource
.
id
,
metricType
:
this
.
templateSrv
.
replace
(
this
.
target
.
metricType
),
aggregation
:
{
crossSeriesReducer
:
'REDUCE_NONE'
,
},
view
:
'HEADERS'
,
},
],
range
:
this
.
timeSrv
.
timeRange
(),
});
const
data
=
await
this
.
datasource
.
getLabels
(
this
.
target
.
metricType
,
this
.
target
.
refId
);
this
.
metricLabels
=
data
.
results
[
this
.
target
.
refId
].
meta
.
metricLabels
;
this
.
resourceLabels
=
data
.
results
[
this
.
target
.
refId
].
meta
.
resourceLabels
;
resolve
();
}
catch
(
error
)
{
appEvents
.
emit
(
'ds-request-error'
,
'Error loading metric labels for '
+
this
.
target
.
metricType
);
resolve
();
}
});
...
...
public/app/plugins/datasource/stackdriver/specs/query_ctrl.test.ts
View file @
c9ee0542
...
...
@@ -408,7 +408,7 @@ function createCtrlWithFakes(existingFilters?: string[]) {
return
{
type
:
'condition'
,
value
:
val
};
},
};
return
new
StackdriverQueryCtrl
(
null
,
null
,
fakeSegmentServer
,
n
ull
,
n
ew
TemplateSrvStub
());
return
new
StackdriverQueryCtrl
(
null
,
null
,
fakeSegmentServer
,
new
TemplateSrvStub
());
}
function
createTarget
(
existingFilters
?:
string
[])
{
...
...
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