[Alert As Data] Add match_only_text mapping for reason field (#171969)

This commit is contained in:
Shahzad 2023-11-28 17:58:22 +01:00 committed by GitHub
parent e64f475a01
commit 42253b6aba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 0 deletions

View file

@ -41,6 +41,7 @@ import {
EVENT_KIND,
TAGS,
} from '@kbn/rule-data-utils';
import { MultiField } from './types';
export const alertFieldMap = {
[ALERT_ACTION_GROUP]: {
@ -92,6 +93,13 @@ export const alertFieldMap = {
type: 'keyword',
array: false,
required: false,
multi_fields: [
{
flat_name: `${ALERT_REASON}.text`,
name: 'text',
type: 'match_only_text',
},
] as MultiField[],
},
[ALERT_RULE_CATEGORY]: {
type: 'keyword',

View file

@ -242,6 +242,11 @@ describe('mappingFromFieldMap', () => {
},
reason: {
type: 'keyword',
fields: {
text: {
type: 'match_only_text',
},
},
},
rule: {
properties: {

View file

@ -79,6 +79,13 @@ it('matches snapshot', () => {
},
"kibana.alert.reason": Object {
"array": false,
"multi_fields": Array [
Object {
"flat_name": "kibana.alert.reason.text",
"name": "text",
"type": "match_only_text",
},
],
"required": false,
"type": "keyword",
},

View file

@ -26,6 +26,9 @@ Object {
"kibana.alert.reason": Array [
"Failed transactions is 50% in the last 5 mins for service: opbeans-go, env: Not defined, type: request. Alert when > 30%.",
],
"kibana.alert.reason.text": Array [
"Failed transactions is 50% in the last 5 mins for service: opbeans-go, env: Not defined, type: request. Alert when > 30%.",
],
"kibana.alert.rule.category": Array [
"Failed transaction rate threshold",
],
@ -109,6 +112,9 @@ Object {
"kibana.alert.reason": Array [
"Failed transactions is 50% in the last 5 mins for service: opbeans-go, env: Not defined, type: request. Alert when > 30%.",
],
"kibana.alert.reason.text": Array [
"Failed transactions is 50% in the last 5 mins for service: opbeans-go, env: Not defined, type: request. Alert when > 30%.",
],
"kibana.alert.rule.category": Array [
"Failed transaction rate threshold",
],