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
ca77cdc3
Commit
ca77cdc3
authored
Oct 29, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: add aggregation query
parent
b1db0778
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
9 deletions
+27
-9
public/app/plugins/datasource/stackdriver/StackdriverMetricFindQuery.ts
+15
-0
public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx
+1
-0
public/app/plugins/datasource/stackdriver/functions.ts
+9
-1
public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts
+2
-8
No files found.
public/app/plugins/datasource/stackdriver/StackdriverMetricFindQuery.ts
View file @
ca77cdc3
...
...
@@ -2,6 +2,7 @@ import {
extractServicesFromMetricDescriptors
,
getMetricTypesByService
,
getAlignmentOptionsByMetric
,
getAggregationOptionsByMetric
,
}
from
'./functions'
;
import
{
alignmentPeriods
}
from
'./constants'
;
import
has
from
'lodash/has'
;
...
...
@@ -24,6 +25,8 @@ export default class StackdriverMetricFindQuery {
return
this
.
handleAlignersType
(
query
);
case
'alignmentPeriods'
:
return
this
.
handleAlignmentPeriodType
();
case
'aggregations'
:
return
this
.
handleAggregationType
(
query
);
default
:
return
[];
}
...
...
@@ -107,6 +110,18 @@ export default class StackdriverMetricFindQuery {
}));
}
async
handleAggregationType
({
metricType
})
{
if
(
!
metricType
)
{
return
[];
}
const
metricDescriptors
=
await
this
.
datasource
.
getMetricTypes
(
this
.
datasource
.
projectName
);
const
{
valueType
,
metricKind
}
=
metricDescriptors
.
find
(
m
=>
m
.
type
===
metricType
);
return
getAggregationOptionsByMetric
(
valueType
,
metricKind
).
map
(
o
=>
({
...
o
,
expandable
:
true
,
}));
}
handleAlignmentPeriodType
()
{
return
alignmentPeriods
.
map
(
s
=>
({
...
s
,
...
...
public/app/plugins/datasource/stackdriver/components/TemplateQueryComponent.tsx
View file @
ca77cdc3
...
...
@@ -134,6 +134,7 @@ export class StackdriverTemplateQueryComponent extends PureComponent<TemplateQue
</
React
.
Fragment
>
);
case
'alignerns'
:
case
'aggregations'
:
return
(
<
React
.
Fragment
>
<
ServiceSelector
metricDescriptors=
{
this
.
state
.
metricDescriptors
}
onServiceChange=
{
this
.
onServiceChange
}
/>
...
...
public/app/plugins/datasource/stackdriver/functions.ts
View file @
ca77cdc3
import
{
alignOptions
}
from
'./constants'
;
import
{
alignOptions
,
aggOptions
}
from
'./constants'
;
import
uniqBy
from
'lodash/uniqBy'
;
export
const
extractServicesFromMetricDescriptors
=
metricDescriptors
=>
uniqBy
(
metricDescriptors
,
'service'
);
...
...
@@ -13,3 +13,11 @@ export const getAlignmentOptionsByMetric = (metricValueType, metricKind) => {
return
i
.
valueTypes
.
indexOf
(
metricValueType
)
!==
-
1
&&
i
.
metricKinds
.
indexOf
(
metricKind
)
!==
-
1
;
});
};
export
const
getAggregationOptionsByMetric
=
(
valueType
,
metricKind
)
=>
{
return
!
metricKind
?
[]
:
aggOptions
.
filter
(
i
=>
{
return
i
.
valueTypes
.
indexOf
(
valueType
)
!==
-
1
&&
i
.
metricKinds
.
indexOf
(
metricKind
)
!==
-
1
;
});
};
public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts
View file @
ca77cdc3
import
coreModule
from
'app/core/core_module'
;
import
_
from
'lodash'
;
import
*
as
options
from
'./constants'
;
import
{
getAlignmentOptionsByMetric
}
from
'./functions'
;
import
{
getAlignmentOptionsByMetric
,
getAggregationOptionsByMetric
}
from
'./functions'
;
import
kbn
from
'app/core/utils/kbn'
;
export
class
StackdriverAggregation
{
...
...
@@ -49,13 +49,7 @@ export class StackdriverAggregationCtrl {
}
setAggOptions
()
{
this
.
aggOptions
=
!
this
.
target
.
metricKind
?
[]
:
options
.
aggOptions
.
filter
(
i
=>
{
return
(
i
.
valueTypes
.
indexOf
(
this
.
target
.
valueType
)
!==
-
1
&&
i
.
metricKinds
.
indexOf
(
this
.
target
.
metricKind
)
!==
-
1
);
});
this
.
aggOptions
=
getAggregationOptionsByMetric
(
this
.
target
.
valueType
,
this
.
target
.
metricKind
);
if
(
!
this
.
aggOptions
.
find
(
o
=>
o
.
value
===
this
.
target
.
aggregation
.
crossSeriesReducer
))
{
this
.
deselectAggregationOption
(
'REDUCE_NONE'
);
...
...
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