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
251bb09a
Commit
251bb09a
authored
Sep 27, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: convert most common stackdriver units to grafana units if possible
parent
e2bda4d3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
1 deletions
+34
-1
public/app/plugins/datasource/stackdriver/constants.ts
+16
-0
public/app/plugins/datasource/stackdriver/datasource.ts
+14
-0
public/app/plugins/datasource/stackdriver/query_ctrl.ts
+4
-1
No files found.
public/app/plugins/datasource/stackdriver/constants.ts
View file @
251bb09a
...
...
@@ -253,3 +253,19 @@ export const alignmentPeriods = [
{
text
:
'1d'
,
value
:
'+86400s'
},
{
text
:
'1w'
,
value
:
'+604800s'
},
];
export
const
stackdriverUnitMappings
=
{
bit
:
'bits'
,
By
:
'bytes'
,
s
:
's'
,
min
:
'm'
,
h
:
'h'
,
d
:
'd'
,
us
:
'µs'
,
ms
:
'ms'
,
ns
:
'ns'
,
percent
:
'percent'
,
MiBy
:
'mbytes'
,
'By/s'
:
'Bps'
,
GBy
:
'decgbytes'
,
};
public/app/plugins/datasource/stackdriver/datasource.ts
View file @
251bb09a
import
{
stackdriverUnitMappings
}
from
'./constants'
;
/** @ngInject */
export
default
class
StackdriverDatasource
{
id
:
number
;
...
...
@@ -85,6 +86,16 @@ export default class StackdriverDatasource {
return
interpolatedGroupBys
;
}
resolveUnit
(
targets
:
any
[])
{
let
unit
=
'none'
;
if
(
targets
.
length
>
0
&&
targets
.
every
(
t
=>
t
.
unit
===
targets
[
0
].
unit
))
{
if
(
stackdriverUnitMappings
.
hasOwnProperty
(
targets
[
0
].
unit
))
{
unit
=
stackdriverUnitMappings
[
targets
[
0
].
unit
];
}
}
return
unit
;
}
async
query
(
options
)
{
const
result
=
[];
const
data
=
await
this
.
getTimeSeries
(
options
);
...
...
@@ -93,12 +104,15 @@ export default class StackdriverDatasource {
if
(
!
queryRes
.
series
)
{
return
;
}
const
unit
=
this
.
resolveUnit
(
options
.
targets
);
queryRes
.
series
.
forEach
(
series
=>
{
result
.
push
({
target
:
series
.
name
,
datapoints
:
series
.
points
,
refId
:
queryRes
.
refId
,
meta
:
queryRes
.
meta
,
unit
,
});
});
});
...
...
public/app/plugins/datasource/stackdriver/query_ctrl.ts
View file @
251bb09a
...
...
@@ -19,6 +19,7 @@ export class StackdriverQueryCtrl extends QueryCtrl {
id
:
string
;
name
:
string
;
};
unit
:
string
;
metricType
:
string
;
service
:
string
;
refId
:
string
;
...
...
@@ -47,6 +48,7 @@ export class StackdriverQueryCtrl extends QueryCtrl {
metricType
:
this
.
defaultDropdownValue
,
service
:
this
.
defaultServiceValue
,
metric
:
''
,
unit
:
''
,
aggregation
:
{
crossSeriesReducer
:
'REDUCE_MEAN'
,
alignmentPeriod
:
'auto'
,
...
...
@@ -221,7 +223,8 @@ export class StackdriverQueryCtrl extends QueryCtrl {
setMetricType
()
{
this
.
target
.
metricType
=
this
.
metricType
;
const
{
valueType
,
metricKind
}
=
this
.
metricDescriptors
.
find
(
m
=>
m
.
type
===
this
.
target
.
metricType
);
const
{
valueType
,
metricKind
,
unit
}
=
this
.
metricDescriptors
.
find
(
m
=>
m
.
type
===
this
.
target
.
metricType
);
this
.
target
.
unit
=
unit
;
this
.
target
.
valueType
=
valueType
;
this
.
target
.
metricKind
=
metricKind
;
this
.
$scope
.
$broadcast
(
'metricTypeChanged'
);
...
...
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