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 15 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
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pageLoadAssetSize:
mapsLegacy: 116817
mapsLegacyLicensing: 20214
ml: 82187
monitoring: 268612
monitoring: 288612
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our unofficial goal is to ultimately limit all page load asset sizes to 200kb in the next year or so, as teams continue to work reducing the size of their bundles. Is anyone from the monitoring team working to reduce the page load asset size of this bundle? a 20kb increase feels reasonable for now, but I'd like to ask that someone from the monitoring team take a look at the x-pack/plugins/monitoring/target/public/stats.json in one of the many webpack analyzers or visualizers after running node scripts/build_kibana_platform_plugins --focus monitoring --profile?

When I run it I see that the server code is being bundles in the page load bundle, which seems like the best way to fix the limit issue, rather than raising the limit.

image

PS, I'm working on unifying the docs for the best way to diagnose and deal with this stuff now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome! Thank you @spalger 🙇

navigation: 37269
newsfeed: 42228
observability: 89709
Expand Down
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,60 @@
/*
* 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';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { AlertTypeModel } from '../../../../triggers_actions_ui/public/types';
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,
};
}
8 changes: 4 additions & 4 deletions x-pack/plugins/monitoring/public/angular/providers/private.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
*
* @param {[type]} prov [description]
*/
import _ from 'lodash';
import { partial, uniqueId, isObject } from 'lodash';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this has no impact on the size of the bundles since we always load and share a single, complete, lodash instance.


const nextId = _.partial(_.uniqueId, 'privateProvider#');
const nextId = partial(uniqueId, 'privateProvider#');

function name(fn) {
return fn.name || fn.toString().split('\n').shift();
Expand Down Expand Up @@ -141,7 +141,7 @@ export function PrivateProvider() {

const context = {};
let instance = $injector.invoke(prov, context, locals);
if (!_.isObject(instance)) instance = context;
if (!isObject(instance)) instance = context;

privPath.pop();
return instance;
Expand All @@ -155,7 +155,7 @@ export function PrivateProvider() {

if ($delegateId != null && $delegateProv != null) {
instance = instantiate(prov, {
$decorate: _.partial(get, $delegateId, $delegateProv),
$decorate: partial(get, $delegateId, $delegateProv),
});
} else {
instance = instantiate(prov);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import _ from 'lodash';
import { get, isEqual, filter } from 'lodash';
import $ from 'jquery';
import React from 'react';
import { eventBus } from './event_bus';
Expand Down Expand Up @@ -50,12 +50,12 @@ export class ChartTarget extends React.Component {
}

UNSAFE_componentWillReceiveProps(newProps) {
if (this.plot && !_.isEqual(newProps, this.props)) {
if (this.plot && !isEqual(newProps, this.props)) {
const { series, timeRange } = newProps;

const xaxisOptions = this.plot.getAxes().xaxis.options;
xaxisOptions.min = _.get(timeRange, 'min');
xaxisOptions.max = _.get(timeRange, 'max');
xaxisOptions.min = get(timeRange, 'min');
xaxisOptions.max = get(timeRange, 'max');

this.plot.setData(this.filterData(series, newProps.seriesToShow));
this.plot.setupGrid();
Expand All @@ -73,7 +73,7 @@ export class ChartTarget extends React.Component {
}

filterData(data, seriesToShow) {
return _(data).filter(this.filterByShow(seriesToShow)).value();
return filter(data, this.filterByShow(seriesToShow)).value();
}

async getOptions() {
Expand Down Expand Up @@ -128,7 +128,7 @@ export class ChartTarget extends React.Component {
this.handleThorPlotHover = (_event, pos, item, originalPlot) => {
if (this.plot !== originalPlot) {
// the crosshair is set for the original chart already
this.plot.setCrosshair({ x: _.get(pos, 'x') });
this.plot.setCrosshair({ x: get(pos, 'x') });
}
this.props.updateLegend(pos, item);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import _ from 'lodash';
import { debounce, keys, has, includes, isFunction, difference, assign } from 'lodash';
import React from 'react';
import { getLastValue } from './get_last_value';
import { TimeseriesContainer } from './timeseries_container';
Expand All @@ -17,7 +17,7 @@ export class TimeseriesVisualization extends React.Component {
constructor(props) {
super(props);

this.debouncedUpdateLegend = _.debounce(this.updateLegend, DEBOUNCE_SLOW_MS);
this.debouncedUpdateLegend = debounce(this.updateLegend, DEBOUNCE_SLOW_MS);
this.debouncedUpdateLegend = this.debouncedUpdateLegend.bind(this);

this.toggleFilter = this.toggleFilter.bind(this);
Expand All @@ -26,18 +26,18 @@ export class TimeseriesVisualization extends React.Component {

this.state = {
values: {},
seriesToShow: _.keys(values),
seriesToShow: keys(values),
ignoreVisibilityUpdates: false,
};
}

filterLegend(id) {
if (!_.has(this.state.values, id)) {
if (!has(this.state.values, id)) {
return [];
}

const notAllShown = _.keys(this.state.values).length !== this.state.seriesToShow.length;
const isCurrentlyShown = _.includes(this.state.seriesToShow, id);
const notAllShown = keys(this.state.values).length !== this.state.seriesToShow.length;
const isCurrentlyShown = includes(this.state.seriesToShow, id);
const seriesToShow = [];

if (notAllShown && isCurrentlyShown) {
Expand All @@ -59,7 +59,7 @@ export class TimeseriesVisualization extends React.Component {
toggleFilter(_event, id) {
const seriesToShow = this.filterLegend(id);

if (_.isFunction(this.props.onFilter)) {
if (isFunction(this.props.onFilter)) {
this.props.onFilter(seriesToShow);
}
}
Expand Down Expand Up @@ -94,21 +94,21 @@ export class TimeseriesVisualization extends React.Component {
getValuesByX(this.props.series, pos.x, setValueCallback);
}
} else {
_.assign(values, this.getLastValues());
assign(values, this.getLastValues());
}

this.setState({ values });
}

UNSAFE_componentWillReceiveProps(props) {
const values = this.getLastValues(props);
const currentKeys = _.keys(this.state.values);
const keys = _.keys(values);
const diff = _.difference(keys, currentKeys);
const currentKeys = keys(this.state.values);
const valueKeys = keys(values);
const diff = difference(valueKeys, currentKeys);
const nextState = { values: values };

if (diff.length && !this.state.ignoreVisibilityUpdates) {
nextState.seriesToShow = keys;
nextState.seriesToShow = valueKeys;
}

this.setState(nextState);
Expand Down
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 @@ -162,6 +164,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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
EuiHealth,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import _ from 'lodash';
import { get } from 'lodash';
import { ELASTICSEARCH_SYSTEM_ID } from '../../../../common/constants';
import { FormattedMessage } from '@kbn/i18n/react';
import { ListingCallOut } from '../../setup_mode/listing_callout';
Expand Down Expand Up @@ -58,7 +58,7 @@ const getNodeTooltip = (node) => {
return null;
};

const getSortHandler = (type) => (item) => _.get(item, [type, 'summary', 'lastVal']);
const getSortHandler = (type) => (item) => get(item, [type, 'summary', 'lastVal']);
const getColumns = (showCgroupMetricsElasticsearch, setupMode, clusterUuid, alerts) => {
const cols = [];

Expand Down Expand Up @@ -87,7 +87,7 @@ const getColumns = (showCgroupMetricsElasticsearch, setupMode, clusterUuid, aler

let setupModeStatus = null;
if (isSetupModeFeatureEnabled(SetupModeFeature.MetricbeatMigration)) {
const list = _.get(setupMode, 'data.byUuid', {});
const list = get(setupMode, 'data.byUuid', {});
const status = list[node.resolver] || {};
const instance = {
uuid: node.resolver,
Expand Down Expand Up @@ -396,7 +396,7 @@ export function ElasticsearchNodes({ clusterStatus, showCgroupMetricsElasticsear
setupMode.data.totalUniqueInstanceCount
) {
const finishMigrationAction =
_.get(setupMode.meta, 'liveClusterUuid') === clusterUuid
get(setupMode.meta, 'liveClusterUuid') === clusterUuid
? setupMode.shortcutToFinishMigration
: setupMode.openFlyout;

Expand Down
Loading