Skip to content

Commit

Permalink
Tweaks to thresholds and throttle periods
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisronline committed Jul 15, 2020
1 parent ed387dd commit f3fb866
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ interface Props {
setAlertParams: (property: string, value: any) => void;
}

const parseRegex = /(\d+)(\smhd)/;
const parseRegex = /(\d+)([smhd]{1})/;
export const AlertParamDuration: React.FC<Props> = (props: Props) => {
const { name, label, setAlertParams, errors } = props;
const parsed = parseRegex.exec(props.duration);
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/monitoring/server/alerts/base_alert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('BaseAlert', () => {
interval: '1m',
},
tags: [],
throttle: '1m',
throttle: '1d',
},
});
});
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/monitoring/server/alerts/base_alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { MonitoringLicenseService } from '../types';
export class BaseAlert {
public type!: string;
public label!: string;
public defaultThrottle: string = '1m';
public defaultThrottle: string = '1d';
public defaultInterval: string = '1m';
public rawAlert: Alert | undefined;
public isLegacy: boolean = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('ClusterHealthAlert', () => {
const alert = new ClusterHealthAlert();
expect(alert.type).toBe(ALERT_CLUSTER_HEALTH);
expect(alert.label).toBe('Cluster health');
expect(alert.defaultThrottle).toBe('1m');
expect(alert.defaultThrottle).toBe('1d');
// @ts-ignore
expect(alert.actionVariables).toStrictEqual([
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ describe('CpuUsageAlert', () => {
const alert = new CpuUsageAlert();
expect(alert.type).toBe(ALERT_CPU_USAGE);
expect(alert.label).toBe('CPU Usage');
expect(alert.defaultThrottle).toBe('1m');
expect(alert.defaultThrottle).toBe('1d');
// @ts-ignore
expect(alert.defaultParams).toStrictEqual({ threshold: 90, duration: '5m' });
expect(alert.defaultParams).toStrictEqual({ threshold: 85, duration: '5m' });
// @ts-ignore
expect(alert.actionVariables).toStrictEqual([
{
Expand Down
13 changes: 11 additions & 2 deletions x-pack/plugins/monitoring/server/alerts/cpu_usage_alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const FIRING = i18n.translate('xpack.monitoring.alerts.cpuUsage.firing', {
defaultMessage: 'firing',
});

const DEFAULT_THRESHOLD = 90;
const DEFAULT_THRESHOLD = 85;
const DEFAULT_DURATION = '5m';

interface CpuUsageParams {
Expand Down Expand Up @@ -393,7 +393,16 @@ export class CpuUsageAlert extends BaseAlert {
continue;
}

const instance = services.alertInstanceFactory(`${this.type}:${cluster.clusterUuid}`);
const firingNodeUuids = nodes.reduce((list, node) => {
const stat = node.meta as AlertCpuUsageNodeStats;
if (node.shouldFire) {
list.push(stat.nodeId);
}
return list;
}, []);
firingNodeUuids.sort(); // It doesn't matter how we sort, but keep the order consistent
const instanceId = `${this.type}:${cluster.clusterUuid}:${firingNodeUuids.join(',')}`;
const instance = services.alertInstanceFactory(instanceId);
const state = (instance.getState() as unknown) as AlertInstanceState;
const alertInstanceState: AlertInstanceState = { alertStates: state?.alertStates || [] };
let shouldExecuteActions = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('ElasticsearchVersionMismatchAlert', () => {
const alert = new ElasticsearchVersionMismatchAlert();
expect(alert.type).toBe(ALERT_ELASTICSEARCH_VERSION_MISMATCH);
expect(alert.label).toBe('Elasticsearch version mismatch');
expect(alert.defaultThrottle).toBe('1m');
expect(alert.defaultThrottle).toBe('1d');
// @ts-ignore
expect(alert.actionVariables).toStrictEqual([
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('KibanaVersionMismatchAlert', () => {
const alert = new KibanaVersionMismatchAlert();
expect(alert.type).toBe(ALERT_KIBANA_VERSION_MISMATCH);
expect(alert.label).toBe('Kibana version mismatch');
expect(alert.defaultThrottle).toBe('1m');
expect(alert.defaultThrottle).toBe('1d');
// @ts-ignore
expect(alert.actionVariables).toStrictEqual([
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('LicenseExpirationAlert', () => {
const alert = new LicenseExpirationAlert();
expect(alert.type).toBe(ALERT_LICENSE_EXPIRATION);
expect(alert.label).toBe('License expiration');
expect(alert.defaultThrottle).toBe('1m');
expect(alert.defaultThrottle).toBe('1d');
// @ts-ignore
expect(alert.actionVariables).toStrictEqual([
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('LogstashVersionMismatchAlert', () => {
const alert = new LogstashVersionMismatchAlert();
expect(alert.type).toBe(ALERT_LOGSTASH_VERSION_MISMATCH);
expect(alert.label).toBe('Logstash version mismatch');
expect(alert.defaultThrottle).toBe('1m');
expect(alert.defaultThrottle).toBe('1d');
// @ts-ignore
expect(alert.actionVariables).toStrictEqual([
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('NodesChangedAlert', () => {
const alert = new NodesChangedAlert();
expect(alert.type).toBe(ALERT_NODES_CHANGED);
expect(alert.label).toBe('Nodes changed');
expect(alert.defaultThrottle).toBe('1m');
expect(alert.defaultThrottle).toBe('1d');
// @ts-ignore
expect(alert.actionVariables).toStrictEqual([
{
Expand Down

0 comments on commit f3fb866

Please sign in to comment.