diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/adapter_types.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/adapter_types.ts index 8b975feb7a0fa..adb8c811ed57d 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/adapter_types.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/adapter_types.ts @@ -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 { diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/aws/aws_diskio_bytes.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/aws/aws_diskio_bytes.ts index 90146e6de5370..15077c3c64cf7 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/aws/aws_diskio_bytes.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/aws/aws_diskio_bytes.ts @@ -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, @@ -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', @@ -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', diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/aws/aws_diskio_ops.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/aws/aws_diskio_ops.ts index 50394488f5343..3df6124d22a7f 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/aws/aws_diskio_ops.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/aws/aws_diskio_ops.ts @@ -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, @@ -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', @@ -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', diff --git a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/aws/aws_network_bytes.ts b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/aws/aws_network_bytes.ts index 0b62b4d5f29b5..3c9842c4ada8f 100644 --- a/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/aws/aws_network_bytes.ts +++ b/x-pack/legacy/plugins/infra/server/lib/adapters/metrics/models/aws/aws_network_bytes.ts @@ -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, @@ -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', @@ -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',