Skip to content

feat(alerts): Limits eap alert time windows and periods #81916

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

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions static/app/views/alerts/rules/metric/ruleConditionsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,19 @@ class RuleConditionsForm extends PureComponent<Props, State> {
]);
}

if (this.props.dataset === Dataset.EVENTS_ANALYTICS_PLATFORM) {
options = pick(TIME_WINDOW_MAP, [
TimeWindow.FIVE_MINUTES,
TimeWindow.TEN_MINUTES,
TimeWindow.FIFTEEN_MINUTES,
TimeWindow.THIRTY_MINUTES,
TimeWindow.ONE_HOUR,
TimeWindow.TWO_HOURS,
TimeWindow.FOUR_HOURS,
TimeWindow.ONE_DAY,
]);
}

return Object.entries(options).map(([value, label]) => ({
value: parseInt(value, 10),
label: tct('[timeWindow] interval', {
Expand Down
22 changes: 22 additions & 0 deletions static/app/views/alerts/rules/metric/triggers/chart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,24 @@ export const AVAILABLE_TIME_PERIODS: Record<TimeWindow, readonly TimePeriod[]> =
[TimeWindow.ONE_DAY]: [TimePeriod.FOURTEEN_DAYS],
};

const MOST_EAP_TIME_PERIOD = [
TimePeriod.ONE_DAY,
TimePeriod.THREE_DAYS,
TimePeriod.SEVEN_DAYS,
];

const EAP_AVAILABLE_TIME_PERIODS = {
[TimeWindow.ONE_MINUTE]: [], // One minute intervals are not allowed on EAP Alerts
[TimeWindow.FIVE_MINUTES]: MOST_EAP_TIME_PERIOD,
[TimeWindow.TEN_MINUTES]: MOST_EAP_TIME_PERIOD,
[TimeWindow.FIFTEEN_MINUTES]: MOST_EAP_TIME_PERIOD,
[TimeWindow.THIRTY_MINUTES]: MOST_EAP_TIME_PERIOD,
[TimeWindow.ONE_HOUR]: MOST_EAP_TIME_PERIOD,
[TimeWindow.TWO_HOURS]: MOST_EAP_TIME_PERIOD,
[TimeWindow.FOUR_HOURS]: [TimePeriod.SEVEN_DAYS],
[TimeWindow.ONE_DAY]: [TimePeriod.SEVEN_DAYS],
};

const TIME_WINDOW_TO_SESSION_INTERVAL = {
[TimeWindow.THIRTY_MINUTES]: '30m',
[TimeWindow.ONE_HOUR]: '1h',
Expand Down Expand Up @@ -246,6 +264,10 @@ class TriggersChart extends PureComponent<Props, State> {
};
}

if (this.props.dataset === Dataset.EVENTS_ANALYTICS_PLATFORM) {
return EAP_AVAILABLE_TIME_PERIODS;
}

return AVAILABLE_TIME_PERIODS;
}

Expand Down
Loading