Skip to content

Commit

Permalink
[7.11] [Logs UI] Fix the ability to switch to the ratio alert type (#…
Browse files Browse the repository at this point in the history
…87563) (#87630)

Backports the following commits to 7.11:
 - [Logs UI] Fix the ability to switch to the ratio alert type (#87563)
  • Loading branch information
weltenwort authored Jan 7, 2021
1 parent c533245 commit 332653b
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import {
ForLastExpression,
} from '../../../../../../triggers_actions_ui/public';
import {
PartialAlertParams,
Comparator,
isRatioAlert,
PartialAlertParams,
PartialCountAlertParams,
PartialCriteria as PartialCriteriaType,
PartialRatioAlertParams,
ThresholdType,
timeUnitRT,
} from '../../../../../common/alerting/logs/log_threshold/types';
Expand Down Expand Up @@ -47,7 +49,7 @@ interface LogsContextMeta {

const DEFAULT_BASE_EXPRESSION = {
timeSize: 5,
timeUnit: 'm',
timeUnit: 'm' as const,
};

const DEFAULT_FIELD = 'log.level';
Expand All @@ -60,7 +62,9 @@ const createDefaultCriterion = (
? { field: DEFAULT_FIELD, comparator: Comparator.EQ, value }
: { field: undefined, comparator: undefined, value: undefined };

const createDefaultCountAlertParams = (availableFields: LogIndexField[]) => ({
const createDefaultCountAlertParams = (
availableFields: LogIndexField[]
): PartialCountAlertParams => ({
...DEFAULT_BASE_EXPRESSION,
count: {
value: 75,
Expand All @@ -69,15 +73,17 @@ const createDefaultCountAlertParams = (availableFields: LogIndexField[]) => ({
criteria: [createDefaultCriterion(availableFields, 'error')],
});

const createDefaultRatioAlertParams = (availableFields: LogIndexField[]) => ({
const createDefaultRatioAlertParams = (
availableFields: LogIndexField[]
): PartialRatioAlertParams => ({
...DEFAULT_BASE_EXPRESSION,
count: {
value: 2,
comparator: Comparator.GT,
},
criteria: [
createDefaultCriterion(availableFields, 'error'),
createDefaultCriterion([], 'warning'),
[createDefaultCriterion(availableFields, 'error')],
[createDefaultCriterion(availableFields, 'warning')],
],
});

Expand Down

0 comments on commit 332653b

Please sign in to comment.