Skip to content

Commit

Permalink
[Infra UI] Use sum for aggregating AWS metrics. (elastic#43293)
Browse files Browse the repository at this point in the history
* Use sum for aggregations.

* Use cumulative sum/derivative instead of hard coded rate

* Fix typo.

* Add positive_only after derivatives.
  • Loading branch information
skh committed Aug 16, 2019
1 parent 3302275 commit 76d5d66
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export enum InfraMetricModelMetricType {
positive_only = 'positive_only', // eslint-disable-line @typescript-eslint/camelcase
derivative = 'derivative',
count = 'count',
sum = 'sum',
cumulative_sum = 'cumulative_sum', // eslint-disable-line @typescript-eslint/camelcase
}

export interface InfraMetricModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
} from '../../adapter_types';
import { InfraMetric } from '../../../../../graphql/types';

// see discussion in: https://github.com/elastic/kibana/issues/42687

export const awsDiskioBytes: InfraMetricModelCreator = (
timeField,
indexPattern,
Expand All @@ -30,14 +32,24 @@ export const awsDiskioBytes: InfraMetricModelCreator = (
metrics: [
{
field: 'aws.ec2.diskio.write.bytes',
id: 'max-diskio-out',
type: InfraMetricModelMetricType.max,
id: 'sum-diskio-out',
type: InfraMetricModelMetricType.sum,
},
{
id: 'by-second-max-diskio-out',
type: InfraMetricModelMetricType.calculation,
variables: [{ id: 'var-max', name: 'max', field: 'max-diskio-out' }],
script: 'params.max / 300', // TODO: https://github.com/elastic/kibana/issues/42687
id: 'csum-sum-diskio-out',
field: 'sum-diskio-out',
type: InfraMetricModelMetricType.cumulative_sum,
},
{
id: 'deriv-csum-sum-diskio-out',
unit: '1s',
type: InfraMetricModelMetricType.derivative,
field: 'csum-sum-diskio-out',
},
{
id: 'posonly-deriv-csum-sum-diskio-out',
field: 'deriv-csum-sum-diskio-out',
type: InfraMetricModelMetricType.positive_only,
},
],
split_mode: 'everything',
Expand All @@ -47,14 +59,30 @@ export const awsDiskioBytes: InfraMetricModelCreator = (
metrics: [
{
field: 'aws.ec2.diskio.read.bytes',
id: 'max-diskio-in',
type: InfraMetricModelMetricType.max,
id: 'sum-diskio-in',
type: InfraMetricModelMetricType.sum,
},
{
id: 'csum-sum-diskio-in',
field: 'sum-diskio-in',
type: InfraMetricModelMetricType.cumulative_sum,
},
{
id: 'deriv-csum-sum-diskio-in',
unit: '1s',
type: InfraMetricModelMetricType.derivative,
field: 'csum-sum-diskio-in',
},
{
id: 'posonly-deriv-csum-sum-diskio-in',
field: 'deriv-csum-sum-diskio-in',
type: InfraMetricModelMetricType.positive_only,
},
{
id: 'inverted-by-second-max-diskio-in',
id: 'inverted-posonly-deriv-csum-sum-diskio-in',
type: InfraMetricModelMetricType.calculation,
variables: [{ id: 'var-max', name: 'max', field: 'max-diskio-in' }],
script: 'params.max / -300', // TODO: https://github.com/elastic/kibana/issues/42687
variables: [{ id: 'var-rate', name: 'rate', field: 'posonly-deriv-csum-sum-diskio-in' }],
script: 'params.rate * -1',
},
],
split_mode: 'everything',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
} from '../../adapter_types';
import { InfraMetric } from '../../../../../graphql/types';

// see discussion in: https://github.com/elastic/kibana/issues/42687

export const awsDiskioOps: InfraMetricModelCreator = (
timeField,
indexPattern,
Expand All @@ -30,8 +32,24 @@ export const awsDiskioOps: InfraMetricModelCreator = (
metrics: [
{
field: 'aws.ec2.diskio.write.count',
id: 'max-diskio-writes',
type: InfraMetricModelMetricType.max,
id: 'sum-diskio-writes',
type: InfraMetricModelMetricType.sum,
},
{
id: 'csum-sum-diskio-writes',
field: 'sum-diskio-writes',
type: InfraMetricModelMetricType.cumulative_sum,
},
{
id: 'deriv-csum-sum-diskio-writes',
unit: '1s',
type: InfraMetricModelMetricType.derivative,
field: 'csum-sum-diskio-writes',
},
{
id: 'posonly-deriv-csum-sum-diskio-writes',
field: 'deriv-csum-sum-diskio-writes',
type: InfraMetricModelMetricType.positive_only,
},
],
split_mode: 'everything',
Expand All @@ -41,14 +59,32 @@ export const awsDiskioOps: InfraMetricModelCreator = (
metrics: [
{
field: 'aws.ec2.diskio.read.count',
id: 'max-diskio-reads',
type: InfraMetricModelMetricType.max,
id: 'sum-diskio-reads',
type: InfraMetricModelMetricType.sum,
},
{
id: 'csum-sum-diskio-reads',
field: 'sum-diskio-reads',
type: InfraMetricModelMetricType.cumulative_sum,
},
{
id: 'deriv-csum-sum-diskio-reads',
unit: '1s',
type: InfraMetricModelMetricType.derivative,
field: 'csum-sum-diskio-reads',
},
{
id: 'posonly-deriv-csum-sum-diskio-reads',
field: 'deriv-csum-sum-diskio-reads',
type: InfraMetricModelMetricType.positive_only,
},
{
id: 'inverted-avg-diskio-reads',
id: 'inverted-posonly-deriv-csum-sum-diskio-reads',
type: InfraMetricModelMetricType.calculation,
variables: [{ id: 'var-max', name: 'max', field: 'max-diskio-reads' }],
script: 'params.max * -1',
variables: [
{ id: 'var-rate', name: 'rate', field: 'posonly-deriv-csum-sum-diskio-reads' },
],
script: 'params.rate * -1',
},
],
split_mode: 'everything',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
} from '../../adapter_types';
import { InfraMetric } from '../../../../../graphql/types';

// see discussion in: https://github.com/elastic/kibana/issues/42687

export const awsNetworkBytes: InfraMetricModelCreator = (
timeField,
indexPattern,
Expand All @@ -30,14 +32,24 @@ export const awsNetworkBytes: InfraMetricModelCreator = (
metrics: [
{
field: 'aws.ec2.network.out.bytes',
id: 'max-net-out',
type: InfraMetricModelMetricType.max,
id: 'sum-net-out',
type: InfraMetricModelMetricType.sum,
},
{
id: 'by-second-max-net-out',
type: InfraMetricModelMetricType.calculation,
variables: [{ id: 'var-max', name: 'max', field: 'max-net-out' }],
script: 'params.max / 300', // TODO: https://github.com/elastic/kibana/issues/42687
id: 'csum-sum-net-out',
field: 'sum-net-out',
type: InfraMetricModelMetricType.cumulative_sum,
},
{
id: 'deriv-csum-sum-net-out',
unit: '1s',
type: InfraMetricModelMetricType.derivative,
field: 'csum-sum-net-out',
},
{
id: 'posonly-deriv-csum-sum-net-out',
field: 'deriv-csum-sum-net-out',
type: InfraMetricModelMetricType.positive_only,
},
],
split_mode: 'everything',
Expand All @@ -47,14 +59,30 @@ export const awsNetworkBytes: InfraMetricModelCreator = (
metrics: [
{
field: 'aws.ec2.network.in.bytes',
id: 'max-net-in',
type: InfraMetricModelMetricType.max,
id: 'sum-net-in',
type: InfraMetricModelMetricType.sum,
},
{
id: 'csum-sum-net-in',
field: 'sum-net-in',
type: InfraMetricModelMetricType.cumulative_sum,
},
{
id: 'deriv-csum-sum-net-in',
unit: '1s',
type: InfraMetricModelMetricType.derivative,
field: 'csum-sum-net-in',
},
{
id: 'posonly-deriv-csum-sum-net-in',
field: 'deriv-csum-sum-net-in',
type: InfraMetricModelMetricType.positive_only,
},
{
id: 'inverted-by-second-max-net-in',
id: 'inverted-posonly-deriv-csum-sum-net-in',
type: InfraMetricModelMetricType.calculation,
variables: [{ id: 'var-max', name: 'max', field: 'max-net-in' }],
script: 'params.max / -300', // TODO: https://github.com/elastic/kibana/issues/42687
variables: [{ id: 'var-rate', name: 'rate', field: 'posonly-deriv-csum-sum-net-in' }],
script: 'params.rate * -1',
},
],
split_mode: 'everything',
Expand Down

0 comments on commit 76d5d66

Please sign in to comment.