Skip to content

Commit e6963f9

Browse files
committed
fix(aci): anomaly detection fields
1 parent d75491d commit e6963f9

File tree

1 file changed

+88
-54
lines changed
  • static/app/views/detectors/components/forms

1 file changed

+88
-54
lines changed

static/app/views/detectors/components/forms/metric.tsx

Lines changed: 88 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ import {
2525
MobileVital,
2626
WebVital,
2727
} from 'sentry/utils/fields';
28+
import {
29+
AlertRuleSensitivity,
30+
AlertRuleThresholdType,
31+
} from 'sentry/views/alerts/rules/metric/types';
2832

2933
type MetricDetectorKind = 'threshold' | 'change' | 'dynamic';
3034

@@ -179,64 +183,94 @@ function DetectSection() {
179183
],
180184
]}
181185
/>
182-
{kind !== 'dynamic' && (
183-
<Flex column>
184-
{(!kind || kind === 'threshold') && (
185-
<Flex column>
186-
<MutedText>An issue will be created when query value exceeds:</MutedText>
187-
<ThresholdField
186+
<Flex column>
187+
{(!kind || kind === 'threshold') && (
188+
<Flex column>
189+
<MutedText>An issue will be created when query value exceeds:</MutedText>
190+
<ThresholdField
191+
flexibleControlStateSize
192+
inline={false}
193+
hideLabel
194+
placeholder="0"
195+
name="config.low_threshold"
196+
suffix="s"
197+
/>
198+
</Flex>
199+
)}
200+
{kind === 'change' && (
201+
<Flex column>
202+
<MutedText>An issue will be created when query value is:</MutedText>
203+
<Flex align="center" gap={space(1)}>
204+
<ChangePercentField
205+
name="config.low_threshold.change"
206+
placeholder="0"
207+
hideLabel
208+
inline
209+
/>
210+
<span>percent</span>
211+
<DirectionField
212+
name="config.low_threshold.direction"
213+
hideLabel
214+
inline
215+
defaultValue="higher"
188216
flexibleControlStateSize
189-
inline={false}
217+
choices={[
218+
['higher', t('higher')],
219+
['lower', t('lower')],
220+
]}
221+
/>
222+
<span>than the previous</span>
223+
<StyledSelectField
224+
name="config.low_threshold.unit"
190225
hideLabel
191-
placeholder="0"
192-
name="config.low_threshold"
193-
suffix="s"
226+
inline
227+
defaultValue="1 hour"
228+
flexibleControlStateSize
229+
choices={[
230+
['5 minutes', '5 minutes'],
231+
['15 minutes', '15 minutes'],
232+
['1 hour', '1 hour'],
233+
['1 day', '1 day'],
234+
['1 week', '1 week'],
235+
['1 month', '1 month'],
236+
]}
194237
/>
195238
</Flex>
196-
)}
197-
{kind === 'change' && (
198-
<Flex column>
199-
<MutedText>An issue will be created when query value is:</MutedText>
200-
<Flex align="center" gap={space(1)}>
201-
<ChangePercentField
202-
name="config.low_threshold.change"
203-
placeholder="0"
204-
hideLabel
205-
inline
206-
/>
207-
<span>percent</span>
208-
<DirectionField
209-
name="config.low_threshold.direction"
210-
hideLabel
211-
inline
212-
defaultValue="higher"
213-
flexibleControlStateSize
214-
choices={[
215-
['higher', t('higher')],
216-
['lower', t('lower')],
217-
]}
218-
/>
219-
<span>than the previous</span>
220-
<StyledSelectField
221-
name="config.low_threshold.unit"
222-
hideLabel
223-
inline
224-
defaultValue="1 hour"
225-
flexibleControlStateSize
226-
choices={[
227-
['5 minutes', '5 minutes'],
228-
['15 minutes', '15 minutes'],
229-
['1 hour', '1 hour'],
230-
['1 day', '1 day'],
231-
['1 week', '1 week'],
232-
['1 month', '1 month'],
233-
]}
234-
/>
235-
</Flex>
236-
</Flex>
237-
)}
238-
</Flex>
239-
)}
239+
</Flex>
240+
)}
241+
{kind === 'dynamic' && (
242+
<Flex column>
243+
<SelectField
244+
required
245+
name="config.sensitivity"
246+
label={t('Level of responsiveness')}
247+
help={t(
248+
'Choose your level of anomaly responsiveness. Higher thresholds means alerts for most anomalies. Lower thresholds means alerts only for larger ones.'
249+
)}
250+
defaultValue={AlertRuleSensitivity.MEDIUM}
251+
choices={[
252+
[AlertRuleSensitivity.HIGH, t('High')],
253+
[AlertRuleSensitivity.MEDIUM, t('Medium')],
254+
[AlertRuleSensitivity.LOW, t('Low')],
255+
]}
256+
/>
257+
<SelectField
258+
required
259+
name="config.thresholdType"
260+
label={t('Direction of anomaly movement')}
261+
help={t(
262+
'Decide if you want to be alerted to anomalies that are moving above, below, or in both directions in relation to your threshold.'
263+
)}
264+
defaultValue={AlertRuleThresholdType.ABOVE_AND_BELOW}
265+
choices={[
266+
[AlertRuleThresholdType.ABOVE, t('Above')],
267+
[AlertRuleThresholdType.ABOVE_AND_BELOW, t('Above and Below')],
268+
[AlertRuleThresholdType.BELOW, t('Below')],
269+
]}
270+
/>
271+
</Flex>
272+
)}
273+
</Flex>
240274
</Section>
241275
</Container>
242276
);

0 commit comments

Comments
 (0)