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
562f62a7
Unverified
Commit
562f62a7
authored
Oct 08, 2018
by
Daniel Lee
Committed by
GitHub
Oct 08, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13564 from grafana/13562-stackdriver-undefined-name
stackdriver metric name fix. Fixes #13562
parents
ed349075
6fce178e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
13 deletions
+24
-13
public/app/plugins/datasource/stackdriver/datasource.ts
+11
-1
public/app/plugins/datasource/stackdriver/query_filter_ctrl.ts
+4
-8
public/app/plugins/datasource/stackdriver/specs/datasource.test.ts
+9
-4
No files found.
public/app/plugins/datasource/stackdriver/datasource.ts
View file @
562f62a7
...
...
@@ -241,7 +241,17 @@ export default class StackdriverDatasource {
try
{
const
metricsApiPath
=
`v3/projects/
${
projectId
}
/metricDescriptors`
;
const
{
data
}
=
await
this
.
doRequest
(
`
${
this
.
baseUrl
}${
metricsApiPath
}
`
);
return
data
.
metricDescriptors
;
const
metrics
=
data
.
metricDescriptors
.
map
(
m
=>
{
const
[
service
]
=
m
.
type
.
split
(
'/'
);
const
[
serviceShortName
]
=
service
.
split
(
'.'
);
m
.
service
=
service
;
m
.
serviceShortName
=
serviceShortName
;
m
.
displayName
=
m
.
displayName
||
m
.
type
;
return
m
;
});
return
metrics
;
}
catch
(
error
)
{
console
.
log
(
error
);
}
...
...
public/app/plugins/datasource/stackdriver/query_filter_ctrl.ts
View file @
562f62a7
...
...
@@ -96,11 +96,9 @@ export class StackdriverFilterCtrl {
getServicesList
()
{
const
defaultValue
=
{
value
:
this
.
$scope
.
defaultServiceValue
,
text
:
this
.
$scope
.
defaultServiceValue
};
const
services
=
this
.
metricDescriptors
.
map
(
m
=>
{
const
[
service
]
=
m
.
type
.
split
(
'/'
);
const
[
serviceShortName
]
=
service
.
split
(
'.'
);
return
{
value
:
service
,
text
:
serviceShortName
,
value
:
m
.
service
,
text
:
m
.
serviceShortName
,
};
});
...
...
@@ -113,12 +111,10 @@ export class StackdriverFilterCtrl {
getMetricsList
()
{
const
metrics
=
this
.
metricDescriptors
.
map
(
m
=>
{
const
[
service
]
=
m
.
type
.
split
(
'/'
);
const
[
serviceShortName
]
=
service
.
split
(
'.'
);
return
{
service
,
service
:
m
.
service
,
value
:
m
.
type
,
serviceShortName
,
serviceShortName
:
m
.
serviceShortName
,
text
:
m
.
displayName
,
title
:
m
.
description
,
};
...
...
public/app/plugins/datasource/stackdriver/specs/datasource.test.ts
View file @
562f62a7
...
...
@@ -164,11 +164,11 @@ describe('StackdriverDataSource', () => {
metricDescriptors
:
[
{
displayName
:
'test metric name 1'
,
type
:
'test metric type 1'
,
type
:
'compute.googleapis.com/instance/cpu/test-metric-type-1'
,
description
:
'A description'
,
},
{
displayName
:
'test metric name 2'
,
type
:
'test metric type 2'
,
type
:
'logging.googleapis.com/user/logbased-metric-with-no-display-name'
,
},
],
},
...
...
@@ -180,8 +180,13 @@ describe('StackdriverDataSource', () => {
});
it
(
'should return successfully'
,
()
=>
{
expect
(
result
.
length
).
toBe
(
2
);
expect
(
result
[
0
].
type
).
toBe
(
'test metric type 1'
);
expect
(
result
[
0
].
service
).
toBe
(
'compute.googleapis.com'
);
expect
(
result
[
0
].
serviceShortName
).
toBe
(
'compute'
);
expect
(
result
[
0
].
type
).
toBe
(
'compute.googleapis.com/instance/cpu/test-metric-type-1'
);
expect
(
result
[
0
].
displayName
).
toBe
(
'test metric name 1'
);
expect
(
result
[
0
].
description
).
toBe
(
'A description'
);
expect
(
result
[
1
].
type
).
toBe
(
'logging.googleapis.com/user/logbased-metric-with-no-display-name'
);
expect
(
result
[
1
].
displayName
).
toBe
(
'logging.googleapis.com/user/logbased-metric-with-no-display-name'
);
});
});
...
...
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