Skip to content

Commit

Permalink
Removed a possibility to define two different names for Alert types o…
Browse files Browse the repository at this point in the history
…n API and UI level. (#86236)

* Removed a possibility to define two different names for Alert types on API and UI level

* fixed typechecks

* fixed typechecks

* fixed due to comments

* fixed typechecks

* fixed jest tests

* fixed typechecks
  • Loading branch information
YulNaumenko authored Dec 20, 2020
1 parent cb704a2 commit 396018f
Show file tree
Hide file tree
Showing 41 changed files with 24 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
export function getAlertType(): AlertTypeModel {
return {
id: 'example.always-firing',
name: 'Always Fires',
description: 'Alert when called',
iconClass: 'bolt',
documentationUrl: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ function isValueInEnum(enumeratin: Record<string, any>, value: any): boolean {
export function getAlertType(): AlertTypeModel {
return {
id: 'example.people-in-space',
name: 'People Are In Space Right Now',
description: 'Alert when people are in space right now',
iconClass: 'globe',
documentationUrl: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ export function registerApmAlerts(
) {
alertTypeRegistry.register({
id: AlertType.ErrorCount,
name: i18n.translate('xpack.apm.alertTypes.errorCount', {
defaultMessage: 'Error count threshold',
}),
description: i18n.translate('xpack.apm.alertTypes.errorCount.description', {
defaultMessage:
'Alert when the number of errors in a service exceeds a defined threshold.',
Expand Down Expand Up @@ -45,9 +42,6 @@ export function registerApmAlerts(

alertTypeRegistry.register({
id: AlertType.TransactionDuration,
name: i18n.translate('xpack.apm.alertTypes.transactionDuration', {
defaultMessage: 'Transaction duration threshold',
}),
description: i18n.translate(
'xpack.apm.alertTypes.transactionDuration.description',
{
Expand Down Expand Up @@ -82,9 +76,6 @@ export function registerApmAlerts(

alertTypeRegistry.register({
id: AlertType.TransactionErrorRate,
name: i18n.translate('xpack.apm.alertTypes.transactionErrorRate', {
defaultMessage: 'Transaction error rate threshold',
}),
description: i18n.translate(
'xpack.apm.alertTypes.transactionErrorRate.description',
{
Expand Down Expand Up @@ -119,9 +110,6 @@ export function registerApmAlerts(

alertTypeRegistry.register({
id: AlertType.TransactionDurationAnomaly,
name: i18n.translate('xpack.apm.alertTypes.transactionDurationAnomaly', {
defaultMessage: 'Transaction duration anomaly',
}),
description: i18n.translate(
'xpack.apm.alertTypes.transactionDurationAnomaly.description',
{
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/infra/public/alerting/inventory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import { validateMetricThreshold } from './components/validation';
export function createInventoryMetricAlertType(): AlertTypeModel {
return {
id: METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID,
name: i18n.translate('xpack.infra.metrics.inventory.alertFlyout.alertName', {
defaultMessage: 'Inventory',
}),
description: i18n.translate('xpack.infra.metrics.inventory.alertFlyout.alertDescription', {
defaultMessage: 'Alert when the inventory exceeds a defined threshold.',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import { validateExpression } from './validation';
export function getAlertType(): AlertTypeModel {
return {
id: LOG_DOCUMENT_COUNT_ALERT_TYPE_ID,
name: i18n.translate('xpack.infra.logs.alertFlyout.alertName', {
defaultMessage: 'Log threshold',
}),
description: i18n.translate('xpack.infra.logs.alertFlyout.alertDescription', {
defaultMessage: 'Alert when the log aggregation exceeds the threshold.',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import { METRIC_THRESHOLD_ALERT_TYPE_ID } from '../../../server/lib/alerting/met
export function createMetricThresholdAlertType(): AlertTypeModel {
return {
id: METRIC_THRESHOLD_ALERT_TYPE_ID,
name: i18n.translate('xpack.infra.metrics.alertFlyout.alertName', {
defaultMessage: 'Metric threshold',
}),
description: i18n.translate('xpack.infra.metrics.alertFlyout.alertDescription', {
defaultMessage: 'Alert when the metrics aggregation exceeds the threshold.',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { schema } from '@kbn/config-schema';
import { i18n } from '@kbn/i18n';
import { AlertType } from '../../../../../alerts/server';
import {
createInventoryMetricThresholdExecutor,
Expand Down Expand Up @@ -41,7 +42,9 @@ const condition = schema.object({

export const registerMetricInventoryThresholdAlertType = (libs: InfraBackendLibs): AlertType => ({
id: METRIC_INVENTORY_THRESHOLD_ALERT_TYPE_ID,
name: 'Inventory',
name: i18n.translate('xpack.infra.metrics.inventory.alertName', {
defaultMessage: 'Inventory',
}),
validate: {
params: schema.object(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ export async function registerLogThresholdAlertType(

alertingPlugin.registerType({
id: LOG_DOCUMENT_COUNT_ALERT_TYPE_ID,
name: 'Log threshold',
name: i18n.translate('xpack.infra.logs.alertName', {
defaultMessage: 'Log threshold',
}),
validate: {
params: {
validate: (params) => decodeOrThrow(AlertParamsRT)(params),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { schema } from '@kbn/config-schema';
import { i18n } from '@kbn/i18n';
import { AlertType } from '../../../../../alerts/server';
import { METRIC_EXPLORER_AGGREGATIONS } from '../../../../common/http_api/metrics_explorer';
import { createMetricThresholdExecutor, FIRED_ACTIONS } from './metric_threshold_executor';
Expand Down Expand Up @@ -42,7 +43,9 @@ export function registerMetricThresholdAlertType(libs: InfraBackendLibs): AlertT

return {
id: METRIC_THRESHOLD_ALERT_TYPE_ID,
name: 'Metric threshold',
name: i18n.translate('xpack.infra.metrics.alertName', {
defaultMessage: 'Metric threshold',
}),
validate: {
params: schema.object(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ describe('alert_form', () => {
const alertType = {
id: 'alert-type',
iconClass: 'test',
name: 'test-alert',
description: 'Testing',
documentationUrl: 'https://...',
validate: validationMethod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const validate = (inputValues: ValidateOptions): ValidationResult => {
export function createCCRReadExceptionsAlertType(): AlertTypeModel {
return {
id: ALERT_CCR_READ_EXCEPTIONS,
name: ALERT_DETAILS[ALERT_CCR_READ_EXCEPTIONS].label,
description: ALERT_DETAILS[ALERT_CCR_READ_EXCEPTIONS].description,
iconClass: 'bell',
documentationUrl(docLinks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { Expression, Props } from '../components/duration/expression';
export function createCpuUsageAlertType(): AlertTypeModel {
return {
id: ALERT_CPU_USAGE,
name: ALERT_DETAILS[ALERT_CPU_USAGE].label,
description: ALERT_DETAILS[ALERT_CPU_USAGE].description,
iconClass: 'bell',
documentationUrl(docLinks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { ALERT_DISK_USAGE, ALERT_DETAILS } from '../../../common/constants';
export function createDiskUsageAlertType(): AlertTypeModel {
return {
id: ALERT_DISK_USAGE,
name: ALERT_DETAILS[ALERT_DISK_USAGE].label,
description: ALERT_DETAILS[ALERT_DISK_USAGE].description,
iconClass: 'bell',
documentationUrl(docLinks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export function createLegacyAlertTypes(): AlertTypeModel[] {
return LEGACY_ALERTS.map((legacyAlert) => {
return {
id: legacyAlert,
name: LEGACY_ALERT_DETAILS[legacyAlert].label,
description: LEGACY_ALERT_DETAILS[legacyAlert].description,
iconClass: 'bell',
documentationUrl(docLinks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { ALERT_MEMORY_USAGE, ALERT_DETAILS } from '../../../common/constants';
export function createMemoryUsageAlertType(): AlertTypeModel {
return {
id: ALERT_MEMORY_USAGE,
name: ALERT_DETAILS[ALERT_MEMORY_USAGE].label,
description: ALERT_DETAILS[ALERT_MEMORY_USAGE].description,
iconClass: 'bell',
documentationUrl(docLinks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { Expression } from './expression';
export function createMissingMonitoringDataAlertType(): AlertTypeModel {
return {
id: ALERT_MISSING_MONITORING_DATA,
name: ALERT_DETAILS[ALERT_MISSING_MONITORING_DATA].label,
description: ALERT_DETAILS[ALERT_MISSING_MONITORING_DATA].description,
iconClass: 'bell',
documentationUrl(docLinks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export function createThreadPoolRejectionsAlertType(
): AlertTypeModel {
return {
id: alertId,
name: threadPoolAlertDetails.label,
description: threadPoolAlertDetails.description,
iconClass: 'bell',
documentationUrl(docLinks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import { AlertTypeModel } from '../../../../triggers_actions_ui/public';
export function getAlertType(): AlertTypeModel<GeoContainmentAlertParams> {
return {
id: '.geo-containment',
name: i18n.translate('xpack.stackAlerts.geoContainment.name.trackingContainment', {
defaultMessage: 'Tracking containment',
}),
description: i18n.translate('xpack.stackAlerts.geoContainment.descriptionText', {
defaultMessage: 'Alert when an entity is contained within a geo boundary.',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import { AlertTypeModel } from '../../../../triggers_actions_ui/public';
export function getAlertType(): AlertTypeModel<GeoThresholdAlertParams> {
return {
id: '.geo-threshold',
name: i18n.translate('xpack.stackAlerts.geoThreshold.name.trackingThreshold', {
defaultMessage: 'Tracking threshold',
}),
description: i18n.translate('xpack.stackAlerts.geoThreshold.descriptionText', {
defaultMessage: 'Alert when an entity enters or leaves a geo boundary.',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import { AlertTypeModel } from '../../../../triggers_actions_ui/public';
export function getAlertType(): AlertTypeModel<IndexThresholdAlertParams> {
return {
id: '.index-threshold',
name: i18n.translate('xpack.stackAlerts.threshold.ui.alertType.nameText', {
defaultMessage: 'Index threshold',
}),
description: i18n.translate('xpack.stackAlerts.threshold.ui.alertType.descriptionText', {
defaultMessage: 'Alert when an aggregated query meets the threshold.',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export interface GeoContainmentParams {

export function getAlertType(logger: Logger): AlertType<GeoContainmentParams> {
const alertTypeName = i18n.translate('xpack.stackAlerts.geoContainment.alertTypeTitle', {
defaultMessage: 'Geo tracking containment',
defaultMessage: 'Tracking containment',
});

const actionGroupName = i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('alertType', () => {

it('alert type creation structure is the expected value', async () => {
expect(alertType.id).toBe('.geo-containment');
expect(alertType.name).toBe('Geo tracking containment');
expect(alertType.name).toBe('Tracking containment');
expect(alertType.actionGroups).toEqual([
{ id: 'Tracked entity contained', name: 'Tracking containment met' },
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export interface GeoThresholdParams {

export function getAlertType(logger: Logger): AlertType<GeoThresholdParams> {
const alertTypeName = i18n.translate('xpack.stackAlerts.geoThreshold.alertTypeTitle', {
defaultMessage: 'Geo tracking threshold',
defaultMessage: 'Tracking threshold',
});

const actionGroupName = i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('alertType', () => {

it('alert type creation structure is the expected value', async () => {
expect(alertType.id).toBe('.geo-threshold');
expect(alertType.name).toBe('Geo tracking threshold');
expect(alertType.name).toBe('Tracking threshold');
expect(alertType.actionGroups).toEqual([
{ id: 'tracking threshold met', name: 'Tracking threshold met' },
]);
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/stack_alerts/server/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('AlertingBuiltins Plugin', () => {
},
],
"id": ".geo-threshold",
"name": "Geo tracking threshold",
"name": "Tracking threshold",
}
`);

Expand Down
10 changes: 0 additions & 10 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -4742,13 +4742,9 @@
"xpack.apm.alerts.anomalySeverity.minor": "マイナー",
"xpack.apm.alerts.anomalySeverity.scoreDetailsDescription": "スコア{value}以上",
"xpack.apm.alerts.anomalySeverity.warningLabel": "警告",
"xpack.apm.alertTypes.errorCount": "エラー数しきい値",
"xpack.apm.alertTypes.errorCount.defaultActionMessage": "次の条件のため、\\{\\{alertName\\}\\}アラートが実行されています。\n\n- サービス名:\\{\\{context.serviceName\\}\\}\n- 環境:\\{\\{context.environment\\}\\}\n- しきい値\\{\\{context.threshold\\}\\}エラー\n- トリガーされた値:過去\\{\\{context.interval\\}\\}に\\{\\{context.triggerValue\\}\\}件のエラー",
"xpack.apm.alertTypes.transactionDuration": "トランザクション期間のしきい値",
"xpack.apm.alertTypes.transactionDuration.defaultActionMessage": "次の条件のため、\\{\\{alertName\\}\\}アラートが実行されています。\n\n- サービス名:\\{\\{context.serviceName\\}\\}\n- タイプ:\\{\\{context.transactionType\\}\\}\n- 環境:\\{\\{context.environment\\}\\}\n- しきい値:\\{\\{context.threshold\\}\\}ミリ秒\n- トリガーされた値:過去\\{\\{context.interval\\}\\}に\\{\\{context.triggerValue\\}\\}",
"xpack.apm.alertTypes.transactionDurationAnomaly": "トランザクション期間異常",
"xpack.apm.alertTypes.transactionDurationAnomaly.defaultActionMessage": "次の条件のため、\\{\\{alertName\\}\\}アラートが実行されています。\n\n- サービス名:\\{\\{context.serviceName\\}\\}\n- タイプ:\\{\\{context.transactionType\\}\\}\n- 環境:\\{\\{context.environment\\}\\}\n- 重要度しきい値:\\{\\{context.threshold\\}\\}%\n- 重要度値:\\{\\{context.thresholdValue\\}\\}\n",
"xpack.apm.alertTypes.transactionErrorRate": "トランザクションエラー率しきい値",
"xpack.apm.alertTypes.transactionErrorRate.defaultActionMessage": "次の条件のため、\\{\\{alertName\\}\\}アラートが実行されています。\n\n- サービス名:\\{\\{context.serviceName\\}\\}\n- タイプ:\\{\\{context.transactionType\\}\\}\n- 環境:\\{\\{context.environment\\}\\}\n- しきい値:\\{\\{context.threshold\\}\\}%\n- トリガーされた値:過去\\{\\{context.interval\\}\\}にエラーの\\{\\{context.triggerValue\\}\\}%",
"xpack.apm.anomaly_detection.error.invalid_license": "異常検知を使用するには、Elastic Platinumライセンスのサブスクリプションが必要です。このライセンスがあれば、機械学習を活用して、サービスを監視できます。",
"xpack.apm.anomaly_detection.error.missing_read_privileges": "異常検知ジョブを表示するには、機械学習およびAPMの「読み取り」権限が必要です",
Expand Down Expand Up @@ -9280,7 +9276,6 @@
"xpack.infra.logFlyout.setFilterTooltip": "フィルターでイベントを表示",
"xpack.infra.logFlyout.valueColumnLabel": "値",
"xpack.infra.logs.alertFlyout.addCondition": "条件を追加",
"xpack.infra.logs.alertFlyout.alertName": "ログしきい値",
"xpack.infra.logs.alertFlyout.criterionComparatorValueTitle": "比較:値",
"xpack.infra.logs.alertFlyout.criterionFieldTitle": "フィールド",
"xpack.infra.logs.alertFlyout.error.criterionComparatorRequired": "コンパレーターが必要です。",
Expand Down Expand Up @@ -9611,7 +9606,6 @@
"xpack.infra.metrics.alertFlyout.aggregationText.p99": "99パーセンタイル",
"xpack.infra.metrics.alertFlyout.aggregationText.rate": "レート",
"xpack.infra.metrics.alertFlyout.aggregationText.sum": "合計",
"xpack.infra.metrics.alertFlyout.alertName": "メトリックしきい値",
"xpack.infra.metrics.alertFlyout.alertOnNoData": "データがない場合に通知する",
"xpack.infra.metrics.alertFlyout.alertPreviewError": "このアラート条件をプレビューするときにエラーが発生しました",
"xpack.infra.metrics.alertFlyout.alertPreviewErrorDesc": "しばらくたってから再試行するか、詳細を確認してください。",
Expand Down Expand Up @@ -9700,7 +9694,6 @@
"xpack.infra.metrics.expressionItems.components.closablePopoverTitle.closeLabel": "閉じる",
"xpack.infra.metrics.invalidNodeErrorDescription": "構成をよく確認してください",
"xpack.infra.metrics.invalidNodeErrorTitle": "{nodeName} がメトリックデータを収集していないようです",
"xpack.infra.metrics.inventory.alertFlyout.alertName": "インベントリ",
"xpack.infra.metrics.loadingNodeDataText": "データを読み込み中",
"xpack.infra.metrics.missingTSVBModelError": "{nodeType}では{metricId}のTSVBモデルが存在しません",
"xpack.infra.metrics.pluginTitle": "メトリック",
Expand Down Expand Up @@ -19118,7 +19111,6 @@
"xpack.stackAlerts.geoThreshold.indexLabel": "インデックス",
"xpack.stackAlerts.geoThreshold.indexPatternSelectLabel": "インデックスパターン",
"xpack.stackAlerts.geoThreshold.indexPatternSelectPlaceholder": "インデックスパターンを選択",
"xpack.stackAlerts.geoThreshold.name.trackingThreshold": "追跡しきい値",
"xpack.stackAlerts.geoThreshold.noIndexPattern.doThisLinkTextDescription": "インデックスパターンを作成します",
"xpack.stackAlerts.geoThreshold.noIndexPattern.doThisPrefixDescription": "次のことが必要です ",
"xpack.stackAlerts.geoThreshold.noIndexPattern.doThisSuffixDescription": " 地理空間フィールドを含む",
Expand Down Expand Up @@ -19493,7 +19485,6 @@
"xpack.triggersActionsUI.sections.alertForm.renotifyFieldLabel": "通知間隔",
"xpack.triggersActionsUI.sections.alertForm.renotifyWithTooltip": "アラートがアクティブな間にアクションを繰り返す頻度を定義します。",
"xpack.triggersActionsUI.sections.alertForm.selectAlertActionTypeTitle": "アクションタイプを選択してください",
"xpack.triggersActionsUI.sections.alertForm.selectedAlertTypeTitle": "{alertType}",
"xpack.triggersActionsUI.sections.alertForm.unableToAddAction": "デフォルトアクショングループの定義がないのでアクションを追加できません",
"xpack.triggersActionsUI.sections.alertForm.unableToLoadActionsMessage": "コネクターを読み込めません",
"xpack.triggersActionsUI.sections.alertForm.unableToLoadActionTypesMessage": "アクションタイプを読み込めません",
Expand Down Expand Up @@ -20137,7 +20128,6 @@
"xpack.uptime.alerts.monitorStatus.timerangeValueField.ariaLabel": "アラートの範囲のための時間単位の数を入力してください",
"xpack.uptime.alerts.monitorStatus.timerangeValueField.expression": "within",
"xpack.uptime.alerts.monitorStatus.timerangeValueField.value": "最終{value}",
"xpack.uptime.alerts.monitorStatus.title.label": "稼働状況の監視ステータス",
"xpack.uptime.alerts.settings.createConnector": "コネクターを作成",
"xpack.uptime.alerts.timerangeUnitSelectable.daysOption.ariaLabel": "「日」の時間範囲選択項目",
"xpack.uptime.alerts.timerangeUnitSelectable.hoursOption.ariaLabel": "「時間」の時間範囲選択項目",
Expand Down
Loading

0 comments on commit 396018f

Please sign in to comment.