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

[RAM] Add data model for scheduled and recurring snoozes #131019

Merged
merged 60 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
a98faba
[RAM] Add data model for scheduled and recurring snoozes
Zacqary Apr 26, 2022
fdbe1b5
Merge remote-tracking branch 'upstream/main' into 130724-snooze-sched…
Zacqary Apr 26, 2022
bc20443
Update migration tests
Zacqary Apr 26, 2022
de7a37f
Make snoozeIndefinitely required
Zacqary Apr 26, 2022
7fec109
Fix remaining muteAlls
Zacqary Apr 26, 2022
ab4f21b
Replace snoozeEndTime with snoozeSchedule
Zacqary Apr 26, 2022
27c5702
Merge remote-tracking branch 'upstream/main' into 130724-snooze-sched…
Zacqary Apr 26, 2022
29173d8
Fix typecheck
Zacqary Apr 26, 2022
0822788
Merge branch 'main' into 130724-snooze-sched-datamodel
Zacqary Apr 26, 2022
274c0c0
Fix typecheck
Zacqary Apr 26, 2022
cabd5c3
Merge branch '130724-snooze-sched-datamodel' of https://github.com/Za…
Zacqary Apr 26, 2022
7c918a5
Revert muteAll => snoozeIndefinitely rename
Zacqary Apr 27, 2022
5b57cb8
Revert more snoozeIndefinitely refs
Zacqary Apr 27, 2022
5df3868
Revert README
Zacqary Apr 27, 2022
7f8acf1
Merge remote-tracking branch 'upstream/main' into 130724-snooze-sched…
Zacqary Apr 27, 2022
d128eac
Restore updated taskrunner test
Zacqary Apr 27, 2022
59c5a1b
Fix RuleStatusDropdown test
Zacqary Apr 27, 2022
03d2d29
Add timeZone to SO
Zacqary Apr 28, 2022
32344fe
Merge remote-tracking branch 'upstream/main' into 130724-snooze-sched…
Zacqary Apr 28, 2022
e3c28e8
Update timezone usage
Zacqary Apr 28, 2022
b93d460
Implement RRule
Zacqary Apr 28, 2022
f9dfc6e
Merge remote-tracking branch 'upstream/main' into 130724-snooze-sched…
Zacqary Apr 29, 2022
370fd45
Fix task runner test
Zacqary Apr 29, 2022
6dda9a2
Add rrule types
Zacqary Apr 29, 2022
128950f
Push snoozeEndTime from server and fix unsnooze
Zacqary Apr 29, 2022
8f3546f
Fix Jest Tests 5
Zacqary Apr 29, 2022
8b69fad
Fix rulestatusdropdown test
Zacqary Apr 29, 2022
01ae2b2
Fix jest tests 1
Zacqary Apr 29, 2022
3af6c23
Fix snooze_end_time refs in functional tests
Zacqary Apr 29, 2022
c526de9
Fix snooze API integration tests
Zacqary May 2, 2022
6527c36
Move isRuleSnoozed to server
Zacqary May 2, 2022
0f9826b
Merge remote-tracking branch 'upstream/main' into 130724-snooze-sched…
Zacqary May 2, 2022
7eec7af
Update x-pack/plugins/alerting/server/lib/is_rule_snoozed.ts
Zacqary May 4, 2022
41414cb
Require timeZone in rulesnooze
Zacqary May 4, 2022
fda4b4b
Merge remote-tracking branch 'upstream/main' into 130724-snooze-sched…
Zacqary May 4, 2022
d2542a5
Merge remote-tracking branch 'upstream/main' into 130724-snooze-sched…
Zacqary May 4, 2022
fadb744
Merge remote-tracking branch 'upstream/main' into 130724-snooze-sched…
Zacqary May 10, 2022
0603855
Add automatic isSnoozedUntil savedobject flag
Zacqary May 10, 2022
fc99605
Check isSnoozedUntil against now
Zacqary May 10, 2022
857c36f
Fix jest
Zacqary May 11, 2022
4e1cc32
Merge remote-tracking branch 'upstream/main' into 130724-snooze-sched…
Zacqary May 11, 2022
52f281f
Fix typecheck
Zacqary May 11, 2022
92511d2
Merge remote-tracking branch 'upstream/main' into 130724-snooze-sched…
Zacqary May 11, 2022
2434080
Fix jest
Zacqary May 11, 2022
70a2aa7
Fix snoozedUntil date parsing
Zacqary May 11, 2022
3646458
Fix rewriterule
Zacqary May 12, 2022
2c53cb7
Add error handling for RRule
Zacqary May 12, 2022
ed75133
Fix re-snoozing
Zacqary May 16, 2022
20c37dc
Merge remote-tracking branch 'upstream/main' into 130724-snooze-sched…
Zacqary May 16, 2022
083782c
Add comments to rulesnoozetype
Zacqary May 16, 2022
f11125d
Restructure data model to use rRule for everything
Zacqary May 16, 2022
409c606
Fix functional tests
Zacqary May 16, 2022
eb1f391
Fix jest
Zacqary May 17, 2022
ffeb94d
Fix functional tests
Zacqary May 17, 2022
f8fe600
Fix functional tests
Zacqary May 17, 2022
22e839e
Fix functional tests
Zacqary May 18, 2022
25f8f7d
Clarify isRuleSnoozed
Zacqary May 18, 2022
3edaa0c
Merge remote-tracking branch 'upstream/main' into 130724-snooze-sched…
Zacqary May 18, 2022
02baeea
Use rrule to parse byweekday
Zacqary May 18, 2022
07bb7e9
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine May 18, 2022
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
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"@types/mapbox__vector-tile": "1.3.0",
"@types/moment-duration-format": "^2.2.3",
"@types/react-is": "^16.7.1",
"@types/rrule": "^2.2.9",
"JSONStream": "1.3.5",
"abort-controller": "^3.0.0",
"antlr4ts": "^0.5.0-alpha.3",
Expand Down Expand Up @@ -305,6 +306,7 @@
"loader-utils": "^1.2.3",
"lodash": "^4.17.21",
"lru-cache": "^4.1.5",
"luxon": "^2.3.2",
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 a peer dependency of rrule

"lz-string": "^1.4.4",
"mapbox-gl-draw-rectangle-mode": "1.0.4",
"maplibre-gl": "2.1.9",
Expand Down Expand Up @@ -400,6 +402,7 @@
"reselect": "^4.0.0",
"resize-observer-polyfill": "^1.5.1",
"rison-node": "1.0.2",
"rrule": "2.6.4",
"rxjs": "^7.5.5",
"safe-squel": "^5.12.5",
"seedrandom": "^3.0.5",
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/alerting/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export * from './disabled_action_groups';
export * from './rule_notify_when_type';
export * from './parse_duration';
export * from './execution_log_types';
export * from './rule_snooze_type';

export interface AlertingFrameworkHealth {
isSufficientlySecure: boolean;
Expand Down
9 changes: 6 additions & 3 deletions x-pack/plugins/alerting/common/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '@kbn/core/server';
import { RuleNotifyWhenType } from './rule_notify_when_type';
import { RuleSnooze } from './rule_snooze_type';

export type RuleTypeState = Record<string, unknown>;
export type RuleTypeParams = Record<string, unknown>;
Expand Down Expand Up @@ -103,15 +104,17 @@ export interface Rule<Params extends RuleTypeParams = never> {
apiKey: string | null;
apiKeyOwner: string | null;
throttle: string | null;
notifyWhen: RuleNotifyWhenType | null;
muteAll: boolean;
notifyWhen: RuleNotifyWhenType | null;
mutedInstanceIds: string[];
executionStatus: RuleExecutionStatus;
monitoring?: RuleMonitoring;
snoozeEndTime?: Date | null; // Remove ? when this parameter is made available in the public API
snoozeSchedule?: RuleSnooze; // Remove ? when this parameter is made available in the public API
}

export type SanitizedRule<Params extends RuleTypeParams = never> = Omit<Rule<Params>, 'apiKey'>;
export type SanitizedRule<Params extends RuleTypeParams = never> = Omit<Rule<Params>, 'apiKey'> & {
isSnoozedUntil?: string | null;
};
export type ResolvedSanitizedRule<Params extends RuleTypeParams = never> = SanitizedRule<Params> &
Omit<SavedObjectsResolveResponse, 'saved_object'>;

Expand Down
14 changes: 14 additions & 0 deletions x-pack/plugins/alerting/common/rule_snooze_type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export type RuleSnooze = Array<{
pmuellr marked this conversation as resolved.
Show resolved Hide resolved
startTime: string;
duration: number;
timeZone?: string;
Zacqary marked this conversation as resolved.
Show resolved Hide resolved
id?: string;
rRule?: string;
Copy link
Contributor

@XavierM XavierM May 4, 2022

Choose a reason for hiding this comment

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

Maybe we can use the type from the library rrule here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to import rrule outside of /server for now. That increases the alerting plugin bundle size to the point where it doesn't pass CI, so I'd prefer to wait to deal with that until we have a critical reason for including rrule on the frontend.

Copy link
Contributor

Choose a reason for hiding this comment

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

or we can just fork it for now

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant that we can just copy the interface, so our API is well defined

Copy link
Contributor

@kobelb kobelb May 10, 2022

Choose a reason for hiding this comment

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

The following came up when @XavierM and I were talking about timezones over Zoom. I think we should do what @XavierM just suggested where we don't support the complex rRule strings, and instead have a strongly typed object for rRule which is equivalent to the type definition from the rrule library.

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 PR is already very large and duplicating the schema would be a lot of additional code, so I'm tracking this here: #132164

}>;
1 change: 1 addition & 0 deletions x-pack/plugins/alerting/server/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ export {
} from './rule_execution_status';
export { getRecoveredAlerts } from './get_recovered_alerts';
export { createWrappedScopedClusterClientFactory } from './wrap_scoped_cluster_client';
export { isRuleSnoozed, getRuleSnoozeEndTime } from './is_rule_snoozed';
Loading