Skip to content

Commit 735a286

Browse files
authored
[Metrics UI] DIsable No Data checkboxes for doc count alerts (#117194)
1 parent 2f29e30 commit 735a286

File tree

1 file changed

+28
-9
lines changed
  • x-pack/plugins/infra/public/alerting/metric_threshold/components

1 file changed

+28
-9
lines changed

x-pack/plugins/infra/public/alerting/metric_threshold/components/expression.tsx

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ export const Expressions: React.FC<Props> = (props) => {
261261
[alertParams.groupBy]
262262
);
263263

264+
const disableNoData = useMemo(
265+
() => alertParams.criteria?.every((c) => c.aggType === Aggregators.COUNT),
266+
[alertParams.criteria]
267+
);
268+
264269
// Test to see if any of the group fields in groupBy are already filtered down to a single
265270
// group by the filterQuery. If this is the case, then a groupBy is unnecessary, as it would only
266271
// ever produce one group instance
@@ -358,17 +363,21 @@ export const Expressions: React.FC<Props> = (props) => {
358363
>
359364
<EuiPanel color="subdued">
360365
<EuiCheckbox
366+
disabled={disableNoData}
361367
id="metrics-alert-no-data-toggle"
362368
label={
363369
<>
364370
{i18n.translate('xpack.infra.metrics.alertFlyout.alertOnNoData', {
365371
defaultMessage: "Alert me if there's no data",
366372
})}{' '}
367373
<EuiToolTip
368-
content={i18n.translate('xpack.infra.metrics.alertFlyout.noDataHelpText', {
369-
defaultMessage:
370-
'Enable this to trigger the action if the metric(s) do not report any data over the expected time period, or if the alert fails to query Elasticsearch',
371-
})}
374+
content={
375+
(disableNoData ? `${docCountNoDataDisabledHelpText} ` : '') +
376+
i18n.translate('xpack.infra.metrics.alertFlyout.noDataHelpText', {
377+
defaultMessage:
378+
'Enable this to trigger the action if the metric(s) do not report any data over the expected time period, or if the alert fails to query Elasticsearch',
379+
})
380+
}
372381
>
373382
<EuiIcon type="questionInCircle" color="subdued" />
374383
</EuiToolTip>
@@ -488,16 +497,19 @@ export const Expressions: React.FC<Props> = (props) => {
488497
defaultMessage: 'Alert me if a group stops reporting data',
489498
})}{' '}
490499
<EuiToolTip
491-
content={i18n.translate('xpack.infra.metrics.alertFlyout.groupDisappearHelpText', {
492-
defaultMessage:
493-
'Enable this to trigger the action if a previously detected group begins to report no results. This is not recommended for dynamically scaling infrastructures that may rapidly start and stop nodes automatically.',
494-
})}
500+
content={
501+
(disableNoData ? `${docCountNoDataDisabledHelpText} ` : '') +
502+
i18n.translate('xpack.infra.metrics.alertFlyout.groupDisappearHelpText', {
503+
defaultMessage:
504+
'Enable this to trigger the action if a previously detected group begins to report no results. This is not recommended for dynamically scaling infrastructures that may rapidly start and stop nodes automatically.',
505+
})
506+
}
495507
>
496508
<EuiIcon type="questionInCircle" color="subdued" />
497509
</EuiToolTip>
498510
</>
499511
}
500-
disabled={!hasGroupBy}
512+
disabled={disableNoData || !hasGroupBy}
501513
checked={Boolean(hasGroupBy && alertParams.alertOnGroupDisappear)}
502514
onChange={(e) => setAlertParams('alertOnGroupDisappear', e.target.checked)}
503515
/>
@@ -506,6 +518,13 @@ export const Expressions: React.FC<Props> = (props) => {
506518
);
507519
};
508520

521+
const docCountNoDataDisabledHelpText = i18n.translate(
522+
'xpack.infra.metrics.alertFlyout.docCountNoDataDisabledHelpText',
523+
{
524+
defaultMessage: '[This setting is not applicable to the Document Count aggregator.]',
525+
}
526+
);
527+
509528
// required for dynamic import
510529
// eslint-disable-next-line import/no-default-export
511530
export default Expressions;

0 commit comments

Comments
 (0)