Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Logs UI] Fix the ability to switch to the ratio alert type #87563

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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