Skip to content

Commit

Permalink
Merge branch 'main' into exceptions_toast
Browse files Browse the repository at this point in the history
  • Loading branch information
yctercero authored Aug 22, 2024
2 parents d85d05b + a2873c0 commit 6e79d6b
Show file tree
Hide file tree
Showing 42 changed files with 1,230 additions and 359 deletions.
5 changes: 5 additions & 0 deletions .buildkite/pipelines/on_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,11 @@ steps:
preemptible: true
artifact_paths:
"target/plugin_so_types_snapshot.json"
timeout_in_minutes: 30
retry:
automatic:
- exit_status: '-1'
limit: 3

- wait: ~
continue_on_failure: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ $screenHeightBreakpoint: $euiSize * 15;
}

.kbnCollapsibleNav__recentsListGroup {
@include euiYScroll;
max-height: $euiSize * 10;
margin-right: -$euiSizeS;
@include euiYScroll;
}

.kbnCollapsibleNav__solutions {
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-alerting-types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export * from './r_rule_types';
export * from './rule_notify_when_type';
export * from './rule_type_types';
export * from './rule_types';
export * from './rule_flapping';
export * from './search_strategy_types';
12 changes: 12 additions & 0 deletions packages/kbn-alerting-types/rule_flapping.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export const MIN_LOOK_BACK_WINDOW = 2;
export const MAX_LOOK_BACK_WINDOW = 20;
export const MIN_STATUS_CHANGE_THRESHOLD = 2;
export const MAX_STATUS_CHANGE_THRESHOLD = 20;
4 changes: 4 additions & 0 deletions packages/kbn-alerting-types/rule_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ export interface Rule<Params extends RuleTypeParams = never> {
running?: boolean | null;
viewInAppRelativeUrl?: string;
alertDelay?: AlertDelay | null;
flapping?: {
lookBackWindow: number;
statusChangeThreshold: number;
};
}

export type SanitizedRule<Params extends RuleTypeParams = never> = Omit<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ describe('createRule', () => {
alert_delay: {
active: 10,
},
flapping: {
look_back_window: 10,
status_change_threshold: 10,
},
};

const ruleToCreate: CreateRuleBody<RuleTypeParams> = {
Expand Down Expand Up @@ -109,10 +113,18 @@ describe('createRule', () => {
alertDelay: {
active: 10,
},
flapping: {
lookBackWindow: 10,
statusChangeThreshold: 10,
},
};
http.post.mockResolvedValueOnce(resolvedValue);

const result = await createRule({ http, rule: ruleToCreate as CreateRuleBody });
expect(http.post).toHaveBeenCalledWith('/api/alerting/rule', {
body: '{"params":{"aggType":"count","termSize":5,"thresholdComparator":">","timeWindowSize":5,"timeWindowUnit":"m","groupBy":"all","threshold":[1000],"index":[".kibana"],"timeField":"alert.executionStatus.lastExecutionDate"},"consumer":"alerts","schedule":{"interval":"1m"},"tags":[],"name":"test","enabled":true,"throttle":null,"notifyWhen":"onActionGroupChange","rule_type_id":".index-threshold","actions":[{"group":"threshold met","id":"83d4d860-9316-11eb-a145-93ab369a4461","params":{"level":"info","message":"Rule \'{{rule.name}}\' is active for group \'{{context.group}}\':\\n\\n- Value: {{context.value}}\\n- Conditions Met: {{context.conditions}} over {{rule.params.timeWindowSize}}{{rule.params.timeWindowUnit}}\\n- Timestamp: {{context.date}}"},"frequency":{"notify_when":"onActionGroupChange","throttle":null,"summary":false}},{"id":".test-system-action","params":{}}],"alert_delay":{"active":10},"flapping":{"look_back_window":10,"status_change_threshold":10}}',
});

expect(result).toEqual({
actions: [
{
Expand Down Expand Up @@ -169,6 +181,10 @@ describe('createRule', () => {
alertDelay: {
active: 10,
},
flapping: {
lookBackWindow: 10,
statusChangeThreshold: 10,
},
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ const ruleToCreate: CreateRuleBody<RuleTypeParams> = {
alertDelay: {
active: 10,
},
flapping: {
lookBackWindow: 10,
statusChangeThreshold: 10,
},
};

describe('transformCreateRuleBody', () => {
Expand Down Expand Up @@ -96,8 +100,11 @@ describe('transformCreateRuleBody', () => {
},
{ id: '.test-system-action', params: {} },
],

alert_delay: { active: 10 },
flapping: {
look_back_window: 10,
status_change_threshold: 10,
},
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,26 @@

import { RewriteResponseCase } from '@kbn/actions-types';
import { CreateRuleBody } from './types';
import { Rule } from '../../types';

const transformCreateRuleFlapping = (flapping: Rule['flapping']) => {
if (!flapping) {
return flapping;
}

return {
flapping: {
look_back_window: flapping.lookBackWindow,
status_change_threshold: flapping.statusChangeThreshold,
},
};
};

export const transformCreateRuleBody: RewriteResponseCase<CreateRuleBody> = ({
ruleTypeId,
actions = [],
alertDelay,
flapping,
...res
}): any => ({
...res,
Expand Down Expand Up @@ -44,4 +59,5 @@ export const transformCreateRuleBody: RewriteResponseCase<CreateRuleBody> = ({
};
}),
...(alertDelay ? { alert_delay: alertDelay } : {}),
...(flapping !== undefined ? transformCreateRuleFlapping(flapping) : {}),
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export interface CreateRuleBody<Params extends RuleTypeParams = RuleTypeParams>
throttle?: Rule<Params>['throttle'];
notifyWhen?: Rule<Params>['notifyWhen'];
alertDelay?: Rule<Params>['alertDelay'];
flapping?: Rule<Params>['flapping'];
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const ruleToUpdate: UpdateRuleBody<RuleTypeParams> = {
alertDelay: {
active: 10,
},
flapping: {
lookBackWindow: 10,
statusChangeThreshold: 10,
},
};

describe('transformUpdateRuleBody', () => {
Expand Down Expand Up @@ -98,6 +102,10 @@ describe('transformUpdateRuleBody', () => {
},
tags: [],
throttle: null,
flapping: {
look_back_window: 10,
status_change_threshold: 10,
},
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,25 @@

import { RewriteResponseCase } from '@kbn/actions-types';
import { UpdateRuleBody } from './types';
import { Rule } from '../../types';

const transformUpdateRuleFlapping = (flapping: Rule['flapping']) => {
if (!flapping) {
return flapping;
}

return {
flapping: {
look_back_window: flapping.lookBackWindow,
status_change_threshold: flapping.statusChangeThreshold,
},
};
};

export const transformUpdateRuleBody: RewriteResponseCase<UpdateRuleBody> = ({
actions = [],
alertDelay,
flapping,
...res
}): any => ({
...res,
Expand Down Expand Up @@ -41,4 +56,5 @@ export const transformUpdateRuleBody: RewriteResponseCase<UpdateRuleBody> = ({
};
}),
...(alertDelay ? { alert_delay: alertDelay } : {}),
...(flapping !== undefined ? transformUpdateRuleFlapping(flapping) : {}),
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export interface UpdateRuleBody<Params extends RuleTypeParams = RuleTypeParams>
throttle?: Rule<Params>['throttle'];
notifyWhen?: Rule<Params>['notifyWhen'];
alertDelay?: Rule<Params>['alertDelay'];
flapping?: Rule<Params>['flapping'];
}
Loading

0 comments on commit 6e79d6b

Please sign in to comment.