Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Metrics UI] Add inventory metric threshold alerts #64292

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9c07f66
Add new inventory metric threshold alert
phillipb Apr 23, 2020
e9862d1
Add missed file
phillipb Apr 23, 2020
1075656
Merge branch 'master' of https://github.com/elastic/kibana into add-i…
phillipb Apr 23, 2020
70b5513
Fix some types
phillipb Apr 23, 2020
5e033ff
Convert units on client and executor.
phillipb Apr 23, 2020
b0818d7
Move formatters to common. Properly format metrics in alert messages
phillipb Apr 24, 2020
bb77f2e
Merge branch 'master' of https://github.com/elastic/kibana into add-i…
phillipb Apr 27, 2020
e4a35c6
Merge branch 'master' of https://github.com/elastic/kibana into add-i…
phillipb Apr 27, 2020
591e822
Style changes
phillipb Apr 27, 2020
8a009bc
Remove unused files
phillipb Apr 27, 2020
f81a46a
Merge branch 'master' of https://github.com/elastic/kibana into add-i…
phillipb Apr 27, 2020
4416d70
fix test
phillipb Apr 27, 2020
3de0333
Update create
phillipb Apr 28, 2020
f51250a
Merge branch 'master' into add-inventory-metric-threshold-alerts
elasticmachine Apr 28, 2020
36e807f
Merge branch 'master' of https://github.com/elastic/kibana into add-i…
phillipb Apr 28, 2020
6553a6d
Fix signature
phillipb Apr 28, 2020
a857610
Merge branch 'add-inventory-metric-threshold-alerts' of github.com:ph…
phillipb Apr 28, 2020
3a64470
Remove old test. Remove unecessary import
phillipb Apr 28, 2020
7440609
Pass in filter when clicking create alert from context menu
phillipb Apr 28, 2020
5de801e
Merge branch 'master' of https://github.com/elastic/kibana into add-i…
phillipb Apr 28, 2020
d0f0b94
Fix filtering
phillipb Apr 28, 2020
698860c
Fix more types
phillipb Apr 29, 2020
58bf603
Merge branch 'master' of https://github.com/elastic/kibana into add-i…
phillipb Apr 29, 2020
42da994
Fix tests
phillipb Apr 29, 2020
c996568
Merge branch 'master' into add-inventory-metric-threshold-alerts
phillipb Apr 29, 2020
34d1f0b
Fix merge
phillipb Apr 29, 2020
2fe7091
Merge branch 'master' of https://github.com/elastic/kibana into add-i…
phillipb Apr 30, 2020
1886f29
Merge branch 'master' of https://github.com/elastic/kibana into add-i…
phillipb Apr 30, 2020
bc7fa67
Fix merge
phillipb Apr 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { InfraWaffleMapDataFormat } from '../../lib/lib';
import { InfraWaffleMapDataFormat } from './types';
import { createBytesFormatter } from './bytes';

describe('createDataFormatter', () => {
it('should format bytes as bytesDecimal', () => {
const formatter = createBytesFormatter(InfraWaffleMapDataFormat.bytesDecimal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { InfraWaffleMapDataFormat } from '../../lib/lib';
import { formatNumber } from './number';
import { InfraWaffleMapDataFormat } from './types';

/**
* The labels are derived from these two Wikipedia articles.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
*/

import Mustache from 'mustache';
import { InfraWaffleMapDataFormat } from '../../lib/lib';
import { createBytesFormatter } from './bytes';
import { formatNumber } from './number';
import { formatPercent } from './percent';
import { InventoryFormatterType } from '../../../common/inventory_models/types';
import { InventoryFormatterType } from '../inventory_models/types';
import { formatHighPercision } from './high_precision';
import { InfraWaffleMapDataFormat } from './types';

export const FORMATTERS = {
number: formatNumber,
Expand Down
73 changes: 73 additions & 0 deletions x-pack/plugins/infra/common/formatters/snapshot_metric_formats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

enum InfraFormatterType {
number = 'number',
abbreviatedNumber = 'abbreviatedNumber',
bytes = 'bytes',
bits = 'bits',
percent = 'percent',
}

interface MetricFormatter {
formatter: InfraFormatterType;
template: string;
bounds?: { min: number; max: number };
}

interface MetricFormatters {
[key: string]: MetricFormatter;
}

export const METRIC_FORMATTERS: MetricFormatters = {
['count']: { formatter: InfraFormatterType.number, template: '{{value}}' },
['cpu']: {
formatter: InfraFormatterType.percent,
template: '{{value}}',
},
['memory']: {
formatter: InfraFormatterType.percent,
template: '{{value}}',
},
['rx']: { formatter: InfraFormatterType.bits, template: '{{value}}/s' },
['tx']: { formatter: InfraFormatterType.bits, template: '{{value}}/s' },
['logRate']: {
formatter: InfraFormatterType.abbreviatedNumber,
template: '{{value}}/s',
},
['diskIOReadBytes']: {
formatter: InfraFormatterType.bytes,
template: '{{value}}/s',
},
['diskIOWriteBytes']: {
formatter: InfraFormatterType.bytes,
template: '{{value}}/s',
},
['s3BucketSize']: {
formatter: InfraFormatterType.bytes,
template: '{{value}}',
},
['s3TotalRequests']: {
formatter: InfraFormatterType.abbreviatedNumber,
template: '{{value}}',
},
['s3NumberOfObjects']: {
formatter: InfraFormatterType.abbreviatedNumber,
template: '{{value}}',
},
['s3UploadBytes']: {
formatter: InfraFormatterType.bytes,
template: '{{value}}',
},
['s3DownloadBytes']: {
formatter: InfraFormatterType.bytes,
template: '{{value}}',
},
['sqsOldestMessage']: {
formatter: InfraFormatterType.number,
template: '{{value}} seconds',
},
};
11 changes: 11 additions & 0 deletions x-pack/plugins/infra/common/formatters/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export enum InfraWaffleMapDataFormat {
bytesDecimal = 'bytesDecimal',
bitsDecimal = 'bitsDecimal',
abbreviatedNumber = 'abbreviatedNumber',
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,29 @@ import { MetricsAndGroupByToolbarItems } from '../shared/components/metrics_and_
import { CloudToolbarItems } from '../shared/components/cloud_toolbar_items';
import { SnapshotMetricType } from '../types';

export const ec2MetricTypes: SnapshotMetricType[] = [
'cpu',
'rx',
'tx',
'diskIOReadBytes',
'diskIOWriteBytes',
];

export const ec2groupByFields = [
'cloud.availability_zone',
'cloud.machine.type',
'aws.ec2.instance.image.id',
'aws.ec2.instance.state.name',
];

export const AwsEC2ToolbarItems = (props: ToolbarProps) => {
const metricTypes: SnapshotMetricType[] = [
'cpu',
'rx',
'tx',
'diskIOReadBytes',
'diskIOWriteBytes',
];
const groupByFields = [
'cloud.availability_zone',
'cloud.machine.type',
'aws.ec2.instance.image.id',
'aws.ec2.instance.state.name',
];
return (
<>
<CloudToolbarItems {...props} />
<MetricsAndGroupByToolbarItems
{...props}
metricTypes={metricTypes}
groupByFields={groupByFields}
metricTypes={ec2MetricTypes}
groupByFields={ec2groupByFields}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,28 @@ import { MetricsAndGroupByToolbarItems } from '../shared/components/metrics_and_
import { CloudToolbarItems } from '../shared/components/cloud_toolbar_items';
import { SnapshotMetricType } from '../types';

export const rdsMetricTypes: SnapshotMetricType[] = [
'cpu',
'rdsConnections',
'rdsQueriesExecuted',
'rdsActiveTransactions',
'rdsLatency',
];

export const rdsGroupByFields = [
'cloud.availability_zone',
'aws.rds.db_instance.class',
'aws.rds.db_instance.status',
];

export const AwsRDSToolbarItems = (props: ToolbarProps) => {
const metricTypes: SnapshotMetricType[] = [
'cpu',
'rdsConnections',
'rdsQueriesExecuted',
'rdsActiveTransactions',
'rdsLatency',
];
const groupByFields = [
'cloud.availability_zone',
'aws.rds.db_instance.class',
'aws.rds.db_instance.status',
];
return (
<>
<CloudToolbarItems {...props} />
<MetricsAndGroupByToolbarItems
{...props}
metricTypes={metricTypes}
groupByFields={groupByFields}
metricTypes={rdsMetricTypes}
groupByFields={rdsGroupByFields}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,24 @@ import { MetricsAndGroupByToolbarItems } from '../shared/components/metrics_and_
import { CloudToolbarItems } from '../shared/components/cloud_toolbar_items';
import { SnapshotMetricType } from '../types';

export const s3MetricTypes: SnapshotMetricType[] = [
's3BucketSize',
's3NumberOfObjects',
's3TotalRequests',
's3DownloadBytes',
's3UploadBytes',
];

export const s3GroupByFields = ['cloud.region'];

export const AwsS3ToolbarItems = (props: ToolbarProps) => {
const metricTypes: SnapshotMetricType[] = [
's3BucketSize',
's3NumberOfObjects',
's3TotalRequests',
's3DownloadBytes',
's3UploadBytes',
];
const groupByFields = ['cloud.region'];
return (
<>
<CloudToolbarItems {...props} />
<MetricsAndGroupByToolbarItems
{...props}
metricTypes={metricTypes}
groupByFields={groupByFields}
metricTypes={s3MetricTypes}
groupByFields={s3GroupByFields}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@ import { MetricsAndGroupByToolbarItems } from '../shared/components/metrics_and_
import { CloudToolbarItems } from '../shared/components/cloud_toolbar_items';
import { SnapshotMetricType } from '../types';

export const sqsMetricTypes: SnapshotMetricType[] = [
'sqsMessagesVisible',
'sqsMessagesDelayed',
'sqsMessagesSent',
'sqsMessagesEmpty',
'sqsOldestMessage',
];
export const sqsGroupByFields = ['cloud.region'];

export const AwsSQSToolbarItems = (props: ToolbarProps) => {
const metricTypes: SnapshotMetricType[] = [
'sqsMessagesVisible',
'sqsMessagesDelayed',
'sqsMessagesSent',
'sqsMessagesEmpty',
'sqsOldestMessage',
];
const groupByFields = ['cloud.region'];
return (
<>
<CloudToolbarItems {...props} />
<MetricsAndGroupByToolbarItems
{...props}
metricTypes={metricTypes}
groupByFields={groupByFields}
metricTypes={sqsMetricTypes}
groupByFields={sqsGroupByFields}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ import { ToolbarProps } from '../../../public/pages/metrics/inventory_view/compo
import { MetricsAndGroupByToolbarItems } from '../shared/components/metrics_and_groupby_toolbar_items';
import { SnapshotMetricType } from '../types';

export const containerMetricTypes: SnapshotMetricType[] = ['cpu', 'memory', 'rx', 'tx'];
export const containerGroupByFields = [
'host.name',
'cloud.availability_zone',
'cloud.machine.type',
'cloud.project.id',
'cloud.provider',
'service.type',
];

export const ContainerToolbarItems = (props: ToolbarProps) => {
const metricTypes: SnapshotMetricType[] = ['cpu', 'memory', 'rx', 'tx'];
const groupByFields = [
'host.name',
'cloud.availability_zone',
'cloud.machine.type',
'cloud.project.id',
'cloud.provider',
'service.type',
];
return (
<MetricsAndGroupByToolbarItems
{...props}
metricTypes={metricTypes}
groupByFields={groupByFields}
metricTypes={containerMetricTypes}
groupByFields={containerGroupByFields}
/>
);
};
27 changes: 17 additions & 10 deletions x-pack/plugins/infra/common/inventory_models/host/toolbar_items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,27 @@ import { ToolbarProps } from '../../../public/pages/metrics/inventory_view/compo
import { MetricsAndGroupByToolbarItems } from '../shared/components/metrics_and_groupby_toolbar_items';
import { SnapshotMetricType } from '../types';

export const hostMetricTypes: SnapshotMetricType[] = [
'cpu',
'memory',
'load',
'rx',
'tx',
'logRate',
];
export const hostGroupByFields = [
'cloud.availability_zone',
'cloud.machine.type',
'cloud.project.id',
'cloud.provider',
'service.type',
];
export const HostToolbarItems = (props: ToolbarProps) => {
const metricTypes: SnapshotMetricType[] = ['cpu', 'memory', 'load', 'rx', 'tx', 'logRate'];
const groupByFields = [
'cloud.availability_zone',
'cloud.machine.type',
'cloud.project.id',
'cloud.provider',
'service.type',
];
return (
<MetricsAndGroupByToolbarItems
{...props}
metricTypes={metricTypes}
groupByFields={groupByFields}
metricTypes={hostMetricTypes}
groupByFields={hostGroupByFields}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import { ToolbarProps } from '../../../public/pages/metrics/inventory_view/compo
import { MetricsAndGroupByToolbarItems } from '../shared/components/metrics_and_groupby_toolbar_items';
import { SnapshotMetricType } from '../types';

export const podMetricTypes: SnapshotMetricType[] = ['cpu', 'memory', 'rx', 'tx'];
export const podGroupByFields = ['kubernetes.namespace', 'kubernetes.node.name', 'service.type'];

export const PodToolbarItems = (props: ToolbarProps) => {
const metricTypes: SnapshotMetricType[] = ['cpu', 'memory', 'rx', 'tx'];
const groupByFields = ['kubernetes.namespace', 'kubernetes.node.name', 'service.type'];
return (
<MetricsAndGroupByToolbarItems
{...props}
metricTypes={metricTypes}
groupByFields={groupByFields}
metricTypes={podMetricTypes}
groupByFields={podGroupByFields}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { AlertFlyout } from './alert_flyout';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';

export const AlertDropdown = () => {
export const MetricsAlertDropdown = () => {
const [popoverOpen, setPopoverOpen] = useState(false);
const [flyoutVisible, setFlyoutVisible] = useState(false);
const kibana = useKibana();
Expand Down
Loading