[RAC] [LOGS] [8.1.0] Review readability alert reason messages (#120969)

* Add Log [2]

* Add Log [1]

* Add Log [1]

* Finish update log

* Use moment for time unit

* Fix moment and add types for  moment-duration-format

* Remove unsed value ungroupedRatioAlertReasonDescription

* Script trusted to delete the update keys in JP and CZ

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Faisal Kanout 2021-12-20 16:42:00 +03:00 committed by GitHub
parent 9006de6dee
commit f1bb5ea96c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 70 additions and 22 deletions

View file

@ -189,6 +189,7 @@
"@turf/helpers": "6.0.1",
"@turf/length": "^6.0.2",
"@types/jsonwebtoken": "^8.5.6",
"@types/moment-duration-format": "^2.2.3",
"JSONStream": "1.3.5",
"abort-controller": "^3.0.0",
"antlr4ts": "^0.5.0-alpha.3",

View file

@ -248,13 +248,19 @@ export const processUngroupedResults = (
alertFactory: LogThresholdAlertFactory,
alertUpdater: AlertUpdater
) => {
const { count, criteria } = params;
const { count, criteria, timeSize, timeUnit } = params;
const documentCount = results.hits.total.value;
if (checkValueAgainstComparatorMap[count.comparator](documentCount, count.value)) {
const alert = alertFactory(
UNGROUPED_FACTORY_KEY,
getReasonMessageForUngroupedCountAlert(documentCount, count.value, count.comparator),
getReasonMessageForUngroupedCountAlert(
documentCount,
count.value,
count.comparator,
timeSize,
timeUnit
),
documentCount,
count.value
);
@ -279,7 +285,7 @@ export const processUngroupedRatioResults = (
alertFactory: LogThresholdAlertFactory,
alertUpdater: AlertUpdater
) => {
const { count, criteria } = params;
const { count, criteria, timeSize, timeUnit } = params;
const numeratorCount = numeratorResults.hits.total.value;
const denominatorCount = denominatorResults.hits.total.value;
@ -288,7 +294,13 @@ export const processUngroupedRatioResults = (
if (ratio !== undefined && checkValueAgainstComparatorMap[count.comparator](ratio, count.value)) {
const alert = alertFactory(
UNGROUPED_FACTORY_KEY,
getReasonMessageForUngroupedRatioAlert(ratio, count.value, count.comparator),
getReasonMessageForUngroupedRatioAlert(
ratio,
count.value,
count.comparator,
timeSize,
timeUnit
),
ratio,
count.value
);
@ -352,7 +364,7 @@ export const processGroupByResults = (
alertFactory: LogThresholdAlertFactory,
alertUpdater: AlertUpdater
) => {
const { count, criteria } = params;
const { count, criteria, timeSize, timeUnit } = params;
const groupResults = getReducedGroupByResults(results);
@ -366,7 +378,9 @@ export const processGroupByResults = (
documentCount,
count.value,
count.comparator,
group.name
group.name,
timeSize,
timeUnit
),
documentCount,
count.value
@ -393,7 +407,7 @@ export const processGroupByRatioResults = (
alertFactory: LogThresholdAlertFactory,
alertUpdater: AlertUpdater
) => {
const { count, criteria } = params;
const { count, criteria, timeSize, timeUnit } = params;
const numeratorGroupResults = getReducedGroupByResults(numeratorResults);
const denominatorGroupResults = getReducedGroupByResults(denominatorResults);
@ -417,7 +431,9 @@ export const processGroupByRatioResults = (
ratio,
count.value,
count.comparator,
numeratorGroup.name
numeratorGroup.name,
timeSize,
timeUnit
),
ratio,
count.value

View file

@ -6,23 +6,44 @@
*/
import { i18n } from '@kbn/i18n';
import * as moment from 'moment';
import momentDurationFormatSetup from 'moment-duration-format';
momentDurationFormatSetup(moment);
import {
Comparator,
ComparatorToi18nMap,
TimeUnit,
} from '../../../../common/alerting/logs/log_threshold/types';
const getDuration = (timeSize: number, timeUnit: TimeUnit): string => {
switch (timeUnit) {
case 's':
return moment.duration(timeSize, 'seconds').format('s [sec]');
case 'm':
return moment.duration(timeSize, 'minutes').format('m [min]');
case 'h':
return moment.duration(timeSize, 'hours').format('h [hr]');
case 'd':
return moment.duration(timeSize, 'days').format('d [day]');
}
};
export const getReasonMessageForUngroupedCountAlert = (
actualCount: number,
expectedCount: number,
comparator: Comparator
comparator: Comparator,
timeSize: number,
timeUnit: TimeUnit
) =>
i18n.translate('xpack.infra.logs.alerting.threshold.ungroupedCountAlertReasonDescription', {
defaultMessage:
'{actualCount, plural, one {{actualCount} log entry} other {{actualCount} log entries} } ({translatedComparator} {expectedCount}) match the conditions.',
'{actualCount, plural, one {{actualCount} log entry} other {{actualCount} log entries}} in the last {duration}. Alert when ({translatedComparator} {expectedCount}).',
values: {
actualCount,
expectedCount,
translatedComparator: ComparatorToi18nMap[comparator],
duration: getDuration(timeSize, timeUnit),
},
});
@ -30,31 +51,37 @@ export const getReasonMessageForGroupedCountAlert = (
actualCount: number,
expectedCount: number,
comparator: Comparator,
groupName: string
groupName: string,
timeSize: number,
timeUnit: TimeUnit
) =>
i18n.translate('xpack.infra.logs.alerting.threshold.groupedCountAlertReasonDescription', {
defaultMessage:
'{actualCount, plural, one {{actualCount} log entry} other {{actualCount} log entries} } ({translatedComparator} {expectedCount}) match the conditions for {groupName}.',
'{actualCount, plural, one {{actualCount} log entry} other {{actualCount} log entries}} in the last {duration} for {groupName}. Alert when ({translatedComparator} {expectedCount}).',
values: {
actualCount,
expectedCount,
groupName,
translatedComparator: ComparatorToi18nMap[comparator],
duration: getDuration(timeSize, timeUnit),
},
});
export const getReasonMessageForUngroupedRatioAlert = (
actualRatio: number,
expectedRatio: number,
comparator: Comparator
comparator: Comparator,
timeSize: number,
timeUnit: TimeUnit
) =>
i18n.translate('xpack.infra.logs.alerting.threshold.ungroupedRatioAlertReasonDescription', {
defaultMessage:
'The log entries ratio is {actualRatio} ({translatedComparator} {expectedRatio}).',
'The ratio of selected logs is {actualRatio} in the last {duration}. Alert when ({translatedComparator} {expectedRatio}).',
values: {
actualRatio,
expectedRatio,
translatedComparator: ComparatorToi18nMap[comparator],
duration: getDuration(timeSize, timeUnit),
},
});
@ -62,15 +89,18 @@ export const getReasonMessageForGroupedRatioAlert = (
actualRatio: number,
expectedRatio: number,
comparator: Comparator,
groupName: string
groupName: string,
timeSize: number,
timeUnit: TimeUnit
) =>
i18n.translate('xpack.infra.logs.alerting.threshold.groupedRatioAlertReasonDescription', {
defaultMessage:
'The log entries ratio is {actualRatio} ({translatedComparator} {expectedRatio}) for {groupName}.',
'The ratio of selected logs is {actualRatio} in the last {duration} for {groupName}. Alert when ({translatedComparator} {expectedRatio}).',
values: {
actualRatio,
expectedRatio,
groupName,
translatedComparator: ComparatorToi18nMap[comparator],
duration: getDuration(timeSize, timeUnit),
},
});

View file

@ -12529,14 +12529,12 @@
"xpack.infra.logs.alerting.threshold.everythingSeriesName": "ログエントリ",
"xpack.infra.logs.alerting.threshold.fired": "実行",
"xpack.infra.logs.alerting.threshold.groupByActionVariableDescription": "アラートのトリガーを実行するグループの名前",
"xpack.infra.logs.alerting.threshold.groupedRatioAlertReasonDescription": "{groupName}のログエントリ率は{actualRatio}{translatedComparator} {expectedRatio})です。",
"xpack.infra.logs.alerting.threshold.isRatioActionVariableDescription": "このアラートが比率で構成されていたかどうかを示します",
"xpack.infra.logs.alerting.threshold.numeratorConditionsActionVariableDescription": "比率の分子が満たす必要がある条件",
"xpack.infra.logs.alerting.threshold.ratioActionVariableDescription": "2つのセットの条件の比率値",
"xpack.infra.logs.alerting.threshold.ratioCriteriaQueryAText": "クエリA",
"xpack.infra.logs.alerting.threshold.ratioCriteriaQueryBText": "クエリB",
"xpack.infra.logs.alerting.threshold.timestampActionVariableDescription": "アラートがトリガーされた時点のOTCタイムスタンプ",
"xpack.infra.logs.alerting.threshold.ungroupedRatioAlertReasonDescription": "ログエントリ率は{actualRatio}{translatedComparator} {expectedRatio})です。",
"xpack.infra.logs.alertName": "ログしきい値",
"xpack.infra.logs.alerts.dataTimeRangeLabel": "過去{lookback} {timeLabel}のデータ",
"xpack.infra.logs.alerts.dataTimeRangeLabelWithGrouping": "{groupByLabel}でグループ化された、過去{lookback} {timeLabel}のデータ({displayedGroups}/{totalGroups}個のグループを表示)",

View file

@ -12690,16 +12690,12 @@
"xpack.infra.logs.alerting.threshold.everythingSeriesName": "日志条目",
"xpack.infra.logs.alerting.threshold.fired": "已触发",
"xpack.infra.logs.alerting.threshold.groupByActionVariableDescription": "负责触发告警的组的名称",
"xpack.infra.logs.alerting.threshold.groupedCountAlertReasonDescription": "{actualCount, plural, other {{actualCount} 个日志条目} } ({translatedComparator} {expectedCount}) 匹配 {groupName} 的条件。",
"xpack.infra.logs.alerting.threshold.groupedRatioAlertReasonDescription": "{groupName} 的日志条目比率为 {actualRatio} ({translatedComparator} {expectedRatio})。",
"xpack.infra.logs.alerting.threshold.isRatioActionVariableDescription": "表示此告警是否配置了比率",
"xpack.infra.logs.alerting.threshold.numeratorConditionsActionVariableDescription": "比率的分子需要满足的条件",
"xpack.infra.logs.alerting.threshold.ratioActionVariableDescription": "两组条件的比率值",
"xpack.infra.logs.alerting.threshold.ratioCriteriaQueryAText": "查询 A",
"xpack.infra.logs.alerting.threshold.ratioCriteriaQueryBText": "查询 B",
"xpack.infra.logs.alerting.threshold.timestampActionVariableDescription": "触发告警时的 UTC 时间戳",
"xpack.infra.logs.alerting.threshold.ungroupedCountAlertReasonDescription": "{actualCount, plural, other {{actualCount} 个日志条目} } ({translatedComparator} {expectedCount}) 匹配条件。",
"xpack.infra.logs.alerting.threshold.ungroupedRatioAlertReasonDescription": "日志条目比率为 {actualRatio} ({translatedComparator} {expectedRatio})。",
"xpack.infra.logs.alertName": "日志阈值",
"xpack.infra.logs.alerts.dataTimeRangeLabel": "过去 {lookback} {timeLabel}的数据",
"xpack.infra.logs.alerts.dataTimeRangeLabelWithGrouping": "过去 {lookback} {timeLabel}的数据,按 {groupByLabel} 进行分组(显示{displayedGroups}/{totalGroups} 个组)",

View file

@ -6051,6 +6051,13 @@
dependencies:
"@types/node" "*"
"@types/moment-duration-format@^2.2.3":
version "2.2.3"
resolved "https://registry.yarnpkg.com/@types/moment-duration-format/-/moment-duration-format-2.2.3.tgz#247b402fe4652dae4a1daabb0c98325b943c373c"
integrity sha512-NQrnFOX1PTvHY8OH1aLoZntAkc2ad/1Cdl31UWIEaqBpDJ/m5SwfFBtFaX7TBLavASeLxG8DL7rm3NHKCLduaA==
dependencies:
moment ">=2.14.0"
"@types/moment-timezone@^0.5.12":
version "0.5.12"
resolved "https://registry.yarnpkg.com/@types/moment-timezone/-/moment-timezone-0.5.12.tgz#0fb680c03db194fe8ff4551eaeb1eec8d3d80e9f"