Skip to content

Commit

Permalink
[Metrics UI] DIsable No Data checkboxes for doc count alerts (#117194)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacqary authored Nov 5, 2021
1 parent 2f29e30 commit 735a286
Showing 1 changed file with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ export const Expressions: React.FC<Props> = (props) => {
[alertParams.groupBy]
);

const disableNoData = useMemo(
() => alertParams.criteria?.every((c) => c.aggType === Aggregators.COUNT),
[alertParams.criteria]
);

// Test to see if any of the group fields in groupBy are already filtered down to a single
// group by the filterQuery. If this is the case, then a groupBy is unnecessary, as it would only
// ever produce one group instance
Expand Down Expand Up @@ -358,17 +363,21 @@ export const Expressions: React.FC<Props> = (props) => {
>
<EuiPanel color="subdued">
<EuiCheckbox
disabled={disableNoData}
id="metrics-alert-no-data-toggle"
label={
<>
{i18n.translate('xpack.infra.metrics.alertFlyout.alertOnNoData', {
defaultMessage: "Alert me if there's no data",
})}{' '}
<EuiToolTip
content={i18n.translate('xpack.infra.metrics.alertFlyout.noDataHelpText', {
defaultMessage:
'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',
})}
content={
(disableNoData ? `${docCountNoDataDisabledHelpText} ` : '') +
i18n.translate('xpack.infra.metrics.alertFlyout.noDataHelpText', {
defaultMessage:
'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',
})
}
>
<EuiIcon type="questionInCircle" color="subdued" />
</EuiToolTip>
Expand Down Expand Up @@ -488,16 +497,19 @@ export const Expressions: React.FC<Props> = (props) => {
defaultMessage: 'Alert me if a group stops reporting data',
})}{' '}
<EuiToolTip
content={i18n.translate('xpack.infra.metrics.alertFlyout.groupDisappearHelpText', {
defaultMessage:
'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.',
})}
content={
(disableNoData ? `${docCountNoDataDisabledHelpText} ` : '') +
i18n.translate('xpack.infra.metrics.alertFlyout.groupDisappearHelpText', {
defaultMessage:
'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.',
})
}
>
<EuiIcon type="questionInCircle" color="subdued" />
</EuiToolTip>
</>
}
disabled={!hasGroupBy}
disabled={disableNoData || !hasGroupBy}
checked={Boolean(hasGroupBy && alertParams.alertOnGroupDisappear)}
onChange={(e) => setAlertParams('alertOnGroupDisappear', e.target.checked)}
/>
Expand All @@ -506,6 +518,13 @@ export const Expressions: React.FC<Props> = (props) => {
);
};

const docCountNoDataDisabledHelpText = i18n.translate(
'xpack.infra.metrics.alertFlyout.docCountNoDataDisabledHelpText',
{
defaultMessage: '[This setting is not applicable to the Document Count aggregator.]',
}
);

// required for dynamic import
// eslint-disable-next-line import/no-default-export
export default Expressions;

0 comments on commit 735a286

Please sign in to comment.