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

[Monitoring] Thread pool rejections alert #79433

Merged
merged 20 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e976a69
Thread pool rejections first draft
igoristic Oct 5, 2020
db3a723
Merge branch 'master' of https://github.com/elastic/kibana into threa…
igoristic Oct 6, 2020
fea1ee8
Merge branch 'master' of https://github.com/elastic/kibana into threa…
igoristic Oct 6, 2020
71aa34d
Merge branch 'master' of https://github.com/elastic/kibana into threa…
igoristic Oct 6, 2020
1a0156d
Merge branch 'master' of https://github.com/elastic/kibana into threa…
igoristic Oct 6, 2020
6908f61
Merge branch 'master' of https://github.com/elastic/kibana into threa…
igoristic Oct 6, 2020
a666da5
Split search and write rejections to seperate alerts
igoristic Oct 6, 2020
cafa0da
Merge branch 'master' of https://github.com/elastic/kibana into threa…
igoristic Oct 7, 2020
17b4134
Code review feedback
igoristic Oct 7, 2020
acb2162
Merge branch 'master' into threadpool_rejection_alert
kibanamachine Oct 12, 2020
eeb6b35
Merge branch 'master' into threadpool_rejection_alert
kibanamachine Oct 14, 2020
36f80f0
Merge branch 'master' of https://github.com/elastic/kibana into threa…
igoristic Oct 26, 2020
ffd436d
Merge branch 'master' of https://github.com/elastic/kibana into threa…
igoristic Oct 26, 2020
22c8a6d
Optimized page loading and bundle size
igoristic Oct 26, 2020
69aae85
Increased monitoring bundle limit
igoristic Oct 26, 2020
ddcd9d2
Merge branch 'master' of https://github.com/elastic/kibana into threa…
igoristic Oct 28, 2020
617cb32
Merge branch 'master' of https://github.com/elastic/kibana into threa…
igoristic Oct 29, 2020
066a5f4
Removed server app import into the frontend
igoristic Oct 29, 2020
7d2a33d
Fixed tests and bundle size
igoristic Oct 29, 2020
a8772dd
Merge branch 'master' of https://github.com/elastic/kibana into threa…
igoristic Oct 29, 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
4 changes: 4 additions & 0 deletions x-pack/plugins/monitoring/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ export const ALERT_KIBANA_VERSION_MISMATCH = `${ALERT_PREFIX}alert_kibana_versio
export const ALERT_LOGSTASH_VERSION_MISMATCH = `${ALERT_PREFIX}alert_logstash_version_mismatch`;
export const ALERT_MEMORY_USAGE = `${ALERT_PREFIX}alert_jvm_memory_usage`;
export const ALERT_MISSING_MONITORING_DATA = `${ALERT_PREFIX}alert_missing_monitoring_data`;
export const ALERT_THREAD_POOL_SEARCH_REJECTIONS = `${ALERT_PREFIX}alert_thread_pool_search_rejections`;
export const ALERT_THREAD_POOL_WRITE_REJECTIONS = `${ALERT_PREFIX}alert_thread_pool_write_rejections`;

/**
* A listing of all alert types
Expand All @@ -253,6 +255,8 @@ export const ALERTS = [
ALERT_LOGSTASH_VERSION_MISMATCH,
ALERT_MEMORY_USAGE,
ALERT_MISSING_MONITORING_DATA,
ALERT_THREAD_POOL_SEARCH_REJECTIONS,
ALERT_THREAD_POOL_WRITE_REJECTIONS,
];

/**
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/monitoring/common/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export enum AlertMessageTokenType {
export enum AlertParamType {
Duration = 'duration',
Percentage = 'percentage',
Number = 'number',
}

export enum SetupModeFeature {
Expand Down
7 changes: 6 additions & 1 deletion x-pack/plugins/monitoring/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface CommonAlertStackProductFilter extends CommonAlertFilter {

export interface CommonAlertParamDetail {
label: string;
type: AlertParamType;
type?: AlertParamType;
}

export interface CommonAlertParamDetails {
Expand All @@ -51,3 +51,8 @@ export interface CommonAlertParamDetails {
export interface CommonAlertParams {
[name: string]: string | number;
}

export interface ThreadPoolRejectionsAlertParams {
threshold: number;
duration: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { CommonAlertParamDetails } from '../../../../common/types';
import { AlertParamDuration } from '../../flyout_expressions/alert_param_duration';
import { AlertParamType } from '../../../../common/enums';
import { AlertParamPercentage } from '../../flyout_expressions/alert_param_percentage';
import { AlertParamNumber } from '../../flyout_expressions/alert_param_number';

export interface Props {
alertParams: { [property: string]: any };
Expand Down Expand Up @@ -49,6 +50,17 @@ export const Expression: React.FC<Props> = (props) => {
setAlertParams={setAlertParams}
/>
);
case AlertParamType.Number:
return (
<AlertParamNumber
key={alertParamName}
name={alertParamName}
label={details.label}
value={value}
errors={errors[alertParamName]}
setAlertParams={setAlertParams}
/>
);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const AlertParamDuration: React.FC<Props> = (props: Props) => {
}, [unit, value]);

return (
<EuiFormRow label={label} error={errors} isInvalid={errors.length > 0}>
<EuiFormRow label={label} error={errors} isInvalid={errors?.length > 0}>
<EuiFlexGroup>
<EuiFlexItem grow={2}>
<EuiFieldNumber
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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.
*/

import React, { useState } from 'react';
import { EuiFormRow, EuiFieldNumber } from '@elastic/eui';

interface Props {
name: string;
value: number;
label: string;
errors: string[];
setAlertParams: (property: string, value: number) => void;
}
export const AlertParamNumber: React.FC<Props> = (props: Props) => {
const { name, label, setAlertParams, errors } = props;
const [value, setValue] = useState(props.value);
return (
<EuiFormRow label={label} error={errors} isInvalid={errors?.length > 0}>
<EuiFieldNumber
compressed
value={value}
onChange={(e) => {
let newValue = Number(e.target.value);
if (isNaN(newValue)) {
newValue = 0;
}
setValue(newValue);
setAlertParams(name, newValue);
}}
/>
</EuiFormRow>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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.
*/

import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiSpacer } from '@elastic/eui';
import { Expression, Props } from '../components/duration/expression';

import { AlertTypeModel } from '../../../../triggers_actions_ui/public';

import { CommonAlertParamDetails } from '../../../common/types';

interface ThreadPoolTypes {
[key: string]: unknown;
}

interface ThreadPoolRejectionAlertClass {
TYPE: string;
LABEL: string;
PARAM_DETAILS: CommonAlertParamDetails;
}

export function createThreadPoolRejectionsAlertType(
threadPoolAlertClass: ThreadPoolRejectionAlertClass
): AlertTypeModel {
return {
id: threadPoolAlertClass.TYPE,
name: threadPoolAlertClass.LABEL,
iconClass: 'bell',
alertParamsExpression: (props: Props) => (
<>
<EuiSpacer />
<Expression {...props} paramDetails={threadPoolAlertClass.PARAM_DETAILS} />
</>
),
validate: (inputValues: ThreadPoolTypes) => {
const errors: { [key: string]: string[] } = {};
const value = inputValues.threshold as number;
if (value < 0) {
const errStr = i18n.translate('xpack.monitoring.alerts.validation.lessThanZero', {
defaultMessage: 'This value can not be less than zero',
});
errors.threshold = [errStr];
}

if (!inputValues.duration) {
const errStr = i18n.translate('xpack.monitoring.alerts.validation.duration', {
defaultMessage: 'A valid duration is required.',
});
errors.duration = [errStr];
}

return { errors };
},
defaultActionMessage: '{{context.internalFullMessage}}',
requiresAppContext: true,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import {
ALERT_CLUSTER_HEALTH,
ALERT_CPU_USAGE,
ALERT_DISK_USAGE,
ALERT_THREAD_POOL_SEARCH_REJECTIONS,
ALERT_THREAD_POOL_WRITE_REJECTIONS,
ALERT_MEMORY_USAGE,
ALERT_NODES_CHANGED,
ALERT_ELASTICSEARCH_VERSION_MISMATCH,
Expand Down Expand Up @@ -161,6 +163,8 @@ const OVERVIEW_PANEL_ALERTS = [ALERT_CLUSTER_HEALTH, ALERT_LICENSE_EXPIRATION];
const NODES_PANEL_ALERTS = [
ALERT_CPU_USAGE,
ALERT_DISK_USAGE,
ALERT_THREAD_POOL_SEARCH_REJECTIONS,
ALERT_THREAD_POOL_WRITE_REJECTIONS,
ALERT_MEMORY_USAGE,
ALERT_NODES_CHANGED,
ALERT_ELASTICSEARCH_VERSION_MISMATCH,
Expand Down
10 changes: 10 additions & 0 deletions x-pack/plugins/monitoring/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ import { createCpuUsageAlertType } from './alerts/cpu_usage_alert';
import { createMissingMonitoringDataAlertType } from './alerts/missing_monitoring_data_alert';
import { createLegacyAlertTypes } from './alerts/legacy_alert';
import { createDiskUsageAlertType } from './alerts/disk_usage_alert';
import { createThreadPoolRejectionsAlertType } from './alerts/thread_pool_rejections_alert';
import { createMemoryUsageAlertType } from './alerts/memory_usage_alert';

// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { ThreadPoolSearchRejectionsAlert } from '../server/alerts';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { ThreadPoolWriteRejectionsAlert } from '../server/alerts';

interface MonitoringSetupPluginDependencies {
home?: HomePublicPluginSetup;
cloud?: { isCloudEnabled: boolean };
Expand Down Expand Up @@ -78,6 +84,10 @@ export class MonitoringPlugin
alertTypeRegistry.register(createDiskUsageAlertType());
alertTypeRegistry.register(createMemoryUsageAlertType());
alertTypeRegistry.register(createMissingMonitoringDataAlertType());
alertTypeRegistry.register(
createThreadPoolRejectionsAlertType(ThreadPoolSearchRejectionsAlert)
);
alertTypeRegistry.register(createThreadPoolRejectionsAlertType(ThreadPoolWriteRejectionsAlert));

const legacyAlertTypes = createLegacyAlertTypes();
for (const legacyAlertType of legacyAlertTypes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { MonitoringViewBaseController } from '../../../base_controller';
import {
CODE_PATH_ELASTICSEARCH,
ALERT_CPU_USAGE,
ALERT_THREAD_POOL_SEARCH_REJECTIONS,
ALERT_THREAD_POOL_WRITE_REJECTIONS,
ALERT_MISSING_MONITORING_DATA,
ALERT_DISK_USAGE,
ALERT_MEMORY_USAGE,
Expand Down Expand Up @@ -76,6 +78,8 @@ uiRoutes.when('/elasticsearch/nodes/:node/advanced', {
alertTypeIds: [
ALERT_CPU_USAGE,
ALERT_DISK_USAGE,
ALERT_THREAD_POOL_SEARCH_REJECTIONS,
ALERT_THREAD_POOL_WRITE_REJECTIONS,
ALERT_MEMORY_USAGE,
ALERT_MISSING_MONITORING_DATA,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import { MonitoringViewBaseController } from '../../base_controller';
import {
CODE_PATH_ELASTICSEARCH,
ALERT_CPU_USAGE,
ALERT_THREAD_POOL_SEARCH_REJECTIONS,
ALERT_THREAD_POOL_WRITE_REJECTIONS,
ALERT_MISSING_MONITORING_DATA,
ALERT_DISK_USAGE,
ALERT_MEMORY_USAGE,
Expand Down Expand Up @@ -60,6 +62,8 @@ uiRoutes.when('/elasticsearch/nodes/:node', {
alertTypeIds: [
ALERT_CPU_USAGE,
ALERT_DISK_USAGE,
ALERT_THREAD_POOL_SEARCH_REJECTIONS,
ALERT_THREAD_POOL_WRITE_REJECTIONS,
ALERT_MEMORY_USAGE,
ALERT_MISSING_MONITORING_DATA,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
ELASTICSEARCH_SYSTEM_ID,
CODE_PATH_ELASTICSEARCH,
ALERT_CPU_USAGE,
ALERT_THREAD_POOL_SEARCH_REJECTIONS,
ALERT_THREAD_POOL_WRITE_REJECTIONS,
ALERT_MISSING_MONITORING_DATA,
ALERT_DISK_USAGE,
ALERT_MEMORY_USAGE,
Expand Down Expand Up @@ -92,6 +94,8 @@ uiRoutes.when('/elasticsearch/nodes', {
alertTypeIds: [
ALERT_CPU_USAGE,
ALERT_DISK_USAGE,
ALERT_THREAD_POOL_SEARCH_REJECTIONS,
ALERT_THREAD_POOL_WRITE_REJECTIONS,
ALERT_MEMORY_USAGE,
ALERT_MISSING_MONITORING_DATA,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,4 @@ describe('AlertsFactory', () => {
expect(alert).not.toBeNull();
expect(alert?.type).toBe(ALERT_CPU_USAGE);
});

it('should get all', () => {
const alerts = AlertsFactory.getAll();
expect(alerts.length).toBe(10);
});
});
6 changes: 6 additions & 0 deletions x-pack/plugins/monitoring/server/alerts/alerts_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
CpuUsageAlert,
MissingMonitoringDataAlert,
DiskUsageAlert,
ThreadPoolSearchRejectionsAlert,
ThreadPoolWriteRejectionsAlert,
MemoryUsageAlert,
NodesChangedAlert,
ClusterHealthAlert,
Expand All @@ -23,6 +25,8 @@ import {
ALERT_CPU_USAGE,
ALERT_MISSING_MONITORING_DATA,
ALERT_DISK_USAGE,
ALERT_THREAD_POOL_SEARCH_REJECTIONS,
ALERT_THREAD_POOL_WRITE_REJECTIONS,
ALERT_MEMORY_USAGE,
ALERT_NODES_CHANGED,
ALERT_LOGSTASH_VERSION_MISMATCH,
Expand All @@ -37,6 +41,8 @@ export const BY_TYPE = {
[ALERT_CPU_USAGE]: CpuUsageAlert,
[ALERT_MISSING_MONITORING_DATA]: MissingMonitoringDataAlert,
[ALERT_DISK_USAGE]: DiskUsageAlert,
[ALERT_THREAD_POOL_SEARCH_REJECTIONS]: ThreadPoolSearchRejectionsAlert,
[ALERT_THREAD_POOL_WRITE_REJECTIONS]: ThreadPoolWriteRejectionsAlert,
[ALERT_MEMORY_USAGE]: MemoryUsageAlert,
[ALERT_NODES_CHANGED]: NodesChangedAlert,
[ALERT_LOGSTASH_VERSION_MISMATCH]: LogstashVersionMismatchAlert,
Expand Down
17 changes: 10 additions & 7 deletions x-pack/plugins/monitoring/server/alerts/base_alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,18 +269,18 @@ export class BaseAlert {
}

protected async fetchData(
params: CommonAlertParams,
params: CommonAlertParams | unknown,
callCluster: any,
clusters: AlertCluster[],
uiSettings: IUiSettingsClient,
availableCcs: string[]
): Promise<AlertData[]> {
): Promise<Array<AlertData & unknown>> {
// Child should implement
throw new Error('Child classes must implement `fetchData`');
}

protected async processData(
data: AlertData[],
data: Array<AlertData & unknown>,
clusters: AlertCluster[],
services: AlertServices,
logger: Logger,
Expand Down Expand Up @@ -365,15 +365,18 @@ export class BaseAlert {
};
}

protected getUiMessage(alertState: AlertState, item: AlertData): AlertMessage {
protected getUiMessage(
alertState: AlertState | unknown,
item: AlertData | unknown
): AlertMessage {
throw new Error('Child classes must implement `getUiMessage`');
}

protected executeActions(
instance: AlertInstance,
instanceState: AlertInstanceState,
item: AlertData,
cluster: AlertCluster
instanceState: AlertInstanceState | unknown,
item: AlertData | unknown,
cluster?: AlertCluster | unknown
) {
throw new Error('Child classes must implement `executeActions`');
}
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/monitoring/server/alerts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export { BaseAlert } from './base_alert';
export { CpuUsageAlert } from './cpu_usage_alert';
export { MissingMonitoringDataAlert } from './missing_monitoring_data_alert';
export { DiskUsageAlert } from './disk_usage_alert';
export { ThreadPoolSearchRejectionsAlert } from './thread_pool_search_rejections_alert';
export { ThreadPoolWriteRejectionsAlert } from './thread_pool_write_rejections_alert';
export { MemoryUsageAlert } from './memory_usage_alert';
export { ClusterHealthAlert } from './cluster_health_alert';
export { LicenseExpirationAlert } from './license_expiration_alert';
Expand Down
Loading