Skip to content

Commit

Permalink
Limits eap alert time windows and periods
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardgou-sentry committed Dec 10, 2024
1 parent d8ed234 commit ebff99b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
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
21 changes: 21 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,23 @@ 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.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 +263,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

0 comments on commit ebff99b

Please sign in to comment.