mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[RAM] Adds revision to event-log (#153716)
## Summary Follow on from https://github.com/elastic/kibana/pull/151388 & https://github.com/elastic/kibana/pull/147398, which includes the rule's current `revision` when writing to the kibana event-log. Note: Added as `kibana.alert.rule.revision` instead of as ECS field `rule.version` as the [ECS docs](https://www.elastic.co/guide/en/ecs/current/ecs-rule.html#field-rule-version) conflate `version` & `revision` and figured it was best to be explicit. If we do indeed want to use `rule.version` I'll make the change. <p align="center"> <img width="500" src="https://user-images.githubusercontent.com/2946766/233216775-f371f412-dcf6-4ef7-a396-84ec853eebbb.png" /> </p> ### Checklist Delete any items that are not applicable to this PR. - [X] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
This commit is contained in:
parent
d4f2639377
commit
ef64acf405
32 changed files with 121 additions and 58 deletions
|
@ -29,6 +29,7 @@ export interface AlertSummary {
|
|||
errorMessages: Array<{ date: string; message: string }>;
|
||||
alerts: Record<string, AlertStatus>;
|
||||
executionDuration: ExecutionDuration;
|
||||
revision: number;
|
||||
}
|
||||
|
||||
export interface AlertStatus {
|
||||
|
|
|
@ -42,6 +42,7 @@ describe('alertSummaryFromEventLog', () => {
|
|||
"lastRun": undefined,
|
||||
"muteAll": false,
|
||||
"name": "rule-name",
|
||||
"revision": 0,
|
||||
"ruleTypeId": "123",
|
||||
"status": "OK",
|
||||
"statusEndDate": "2020-06-18T01:00:00.000Z",
|
||||
|
@ -88,6 +89,7 @@ describe('alertSummaryFromEventLog', () => {
|
|||
"lastRun": undefined,
|
||||
"muteAll": true,
|
||||
"name": "rule-name-2",
|
||||
"revision": 0,
|
||||
"ruleTypeId": "456",
|
||||
"status": "OK",
|
||||
"statusEndDate": "2020-06-18T03:00:00.000Z",
|
||||
|
|
|
@ -40,6 +40,7 @@ export function alertSummaryFromEventLog(params: AlertSummaryFromEventLogParams)
|
|||
average: 0,
|
||||
valuesWithTimestamp: {},
|
||||
},
|
||||
revision: rule.revision,
|
||||
};
|
||||
|
||||
const alerts = new Map<string, AlertStatus>();
|
||||
|
|
|
@ -55,6 +55,7 @@ const context: RuleContextOpts = {
|
|||
spaceId: 'test-space',
|
||||
executionId: 'abcd-efgh-ijklmnop',
|
||||
taskScheduledAt: new Date('2020-01-01T00:00:00.000Z'),
|
||||
ruleRevision: 0,
|
||||
};
|
||||
|
||||
const contextWithScheduleDelay = { ...context, taskScheduleDelay: 7200000 };
|
||||
|
|
|
@ -30,6 +30,7 @@ export interface RuleContextOpts {
|
|||
executionId: string;
|
||||
taskScheduledAt: Date;
|
||||
ruleName?: string;
|
||||
ruleRevision?: number;
|
||||
}
|
||||
|
||||
type RuleContext = RuleContextOpts & {
|
||||
|
@ -266,6 +267,7 @@ export function createAlertRecord(context: RuleContextOpts, alert: AlertOpts) {
|
|||
ruleName: context.ruleName,
|
||||
flapping: alert.flapping,
|
||||
maintenanceWindowIds: alert.maintenanceWindowIds,
|
||||
ruleRevision: context.ruleRevision,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -296,6 +298,7 @@ export function createActionExecuteRecord(context: RuleContextOpts, action: Acti
|
|||
],
|
||||
ruleName: context.ruleName,
|
||||
alertSummary: action.alertSummary,
|
||||
ruleRevision: context.ruleRevision,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -322,6 +325,7 @@ export function createExecuteTimeoutRecord(context: RuleContextOpts) {
|
|||
},
|
||||
],
|
||||
ruleName: context.ruleName,
|
||||
ruleRevision: context.ruleRevision,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -334,6 +338,7 @@ export function initializeExecuteRecord(context: RuleContext) {
|
|||
spaceId: context.spaceId,
|
||||
executionId: context.executionId,
|
||||
action: EVENT_LOG_ACTIONS.execute,
|
||||
ruleRevision: context.ruleRevision,
|
||||
task: {
|
||||
scheduled: context.taskScheduledAt.toISOString(),
|
||||
scheduleDelay: Millis2Nanos * context.taskScheduleDelay,
|
||||
|
|
|
@ -36,6 +36,7 @@ describe('createAlertEventLogRecordObject', () => {
|
|||
ruleType,
|
||||
consumer: 'rule-consumer',
|
||||
action: 'execute-start',
|
||||
ruleRevision: 0,
|
||||
timestamp: '1970-01-01T00:00:00.000Z',
|
||||
task: {
|
||||
scheduled: '1970-01-01T00:00:00.000Z',
|
||||
|
@ -66,6 +67,7 @@ describe('createAlertEventLogRecordObject', () => {
|
|||
execution: {
|
||||
uuid: '7a7065d7-6e8b-4aae-8d20-c93613dec9fb',
|
||||
},
|
||||
revision: 0,
|
||||
rule_type_id: 'test',
|
||||
},
|
||||
maintenance_window_ids: MAINTENANCE_WINDOW_IDS,
|
||||
|
@ -107,6 +109,7 @@ describe('createAlertEventLogRecordObject', () => {
|
|||
group: 'group 1',
|
||||
message: 'message text here',
|
||||
namespace: 'default',
|
||||
ruleRevision: 0,
|
||||
state: {
|
||||
start: '1970-01-01T00:00:00.000Z',
|
||||
end: '1970-01-01T00:05:00.000Z',
|
||||
|
@ -139,6 +142,7 @@ describe('createAlertEventLogRecordObject', () => {
|
|||
execution: {
|
||||
uuid: '7a7065d7-6e8b-4aae-8d20-c93613dec9fb',
|
||||
},
|
||||
revision: 0,
|
||||
rule_type_id: 'test',
|
||||
},
|
||||
maintenance_window_ids: MAINTENANCE_WINDOW_IDS,
|
||||
|
@ -182,6 +186,7 @@ describe('createAlertEventLogRecordObject', () => {
|
|||
group: 'group 1',
|
||||
message: 'action execution start',
|
||||
namespace: 'default',
|
||||
ruleRevision: 0,
|
||||
state: {
|
||||
start: '1970-01-01T00:00:00.000Z',
|
||||
end: '1970-01-01T00:05:00.000Z',
|
||||
|
@ -224,6 +229,7 @@ describe('createAlertEventLogRecordObject', () => {
|
|||
execution: {
|
||||
uuid: '7a7065d7-6e8b-4aae-8d20-c93613dec9fb',
|
||||
},
|
||||
revision: 0,
|
||||
rule_type_id: 'test',
|
||||
},
|
||||
maintenance_window_ids: MAINTENANCE_WINDOW_IDS,
|
||||
|
|
|
@ -43,6 +43,7 @@ interface CreateAlertEventLogRecordParams {
|
|||
recovered: number;
|
||||
};
|
||||
maintenanceWindowIds?: string[];
|
||||
ruleRevision?: number;
|
||||
}
|
||||
|
||||
export function createAlertEventLogRecordObject(params: CreateAlertEventLogRecordParams): Event {
|
||||
|
@ -62,6 +63,7 @@ export function createAlertEventLogRecordObject(params: CreateAlertEventLogRecor
|
|||
alertUuid,
|
||||
alertSummary,
|
||||
maintenanceWindowIds,
|
||||
ruleRevision,
|
||||
} = params;
|
||||
const alerting =
|
||||
params.instanceId || group || alertSummary
|
||||
|
@ -97,6 +99,7 @@ export function createAlertEventLogRecordObject(params: CreateAlertEventLogRecor
|
|||
...(maintenanceWindowIds ? { maintenance_window_ids: maintenanceWindowIds } : {}),
|
||||
...(alertUuid ? { uuid: alertUuid } : {}),
|
||||
rule: {
|
||||
revision: ruleRevision,
|
||||
rule_type_id: ruleType.id,
|
||||
...(consumer ? { consumer } : {}),
|
||||
...(executionId
|
||||
|
|
|
@ -38,6 +38,7 @@ describe('getRuleAlertSummaryRoute', () => {
|
|||
status: 'OK',
|
||||
errorMessages: [],
|
||||
alerts: {},
|
||||
revision: 0,
|
||||
executionDuration: {
|
||||
average: 1,
|
||||
valuesWithTimestamp: {
|
||||
|
|
|
@ -47,6 +47,7 @@ describe('getAlertInstanceSummaryRoute', () => {
|
|||
average: 0,
|
||||
valuesWithTimestamp: {},
|
||||
},
|
||||
revision: 0,
|
||||
};
|
||||
|
||||
it('gets alert instance summary', async () => {
|
||||
|
|
|
@ -43,6 +43,7 @@ export const recoverRuleAlerts = async (
|
|||
const event = createAlertEventLogRecordObject({
|
||||
ruleId: id,
|
||||
ruleName: attributes.name,
|
||||
ruleRevision: attributes.revision,
|
||||
ruleType: context.ruleTypeRegistry.get(attributes.alertTypeId),
|
||||
consumer: attributes.consumer,
|
||||
instanceId: alertId,
|
||||
|
|
|
@ -100,6 +100,7 @@ describe('disable()', () => {
|
|||
schedule: { interval: '10s' },
|
||||
alertTypeId: 'myType',
|
||||
enabled: true,
|
||||
revision: 0,
|
||||
scheduledTaskId: '1',
|
||||
actions: [
|
||||
{
|
||||
|
@ -224,6 +225,7 @@ describe('disable()', () => {
|
|||
meta: {
|
||||
versionApiKeyLastmodified: 'v7.10.0',
|
||||
},
|
||||
revision: 0,
|
||||
scheduledTaskId: '1',
|
||||
apiKey: 'MTIzOmFiYw==',
|
||||
apiKeyOwner: 'elastic',
|
||||
|
@ -277,6 +279,7 @@ describe('disable()', () => {
|
|||
},
|
||||
params: {
|
||||
alertId: '1',
|
||||
revision: 0,
|
||||
},
|
||||
ownerId: null,
|
||||
});
|
||||
|
@ -296,6 +299,7 @@ describe('disable()', () => {
|
|||
meta: {
|
||||
versionApiKeyLastmodified: 'v7.10.0',
|
||||
},
|
||||
revision: 0,
|
||||
scheduledTaskId: '1',
|
||||
apiKey: 'MTIzOmFiYw==',
|
||||
apiKeyOwner: 'elastic',
|
||||
|
@ -333,6 +337,7 @@ describe('disable()', () => {
|
|||
uuid: 'uuid-1',
|
||||
rule: {
|
||||
consumer: 'myApp',
|
||||
revision: 0,
|
||||
rule_type_id: '123',
|
||||
},
|
||||
},
|
||||
|
@ -379,6 +384,7 @@ describe('disable()', () => {
|
|||
meta: {
|
||||
versionApiKeyLastmodified: 'v7.10.0',
|
||||
},
|
||||
revision: 0,
|
||||
scheduledTaskId: '1',
|
||||
apiKey: 'MTIzOmFiYw==',
|
||||
apiKeyOwner: 'elastic',
|
||||
|
@ -425,6 +431,7 @@ describe('disable()', () => {
|
|||
schedule: { interval: '10s' },
|
||||
alertTypeId: 'myType',
|
||||
enabled: false,
|
||||
revision: 0,
|
||||
scheduledTaskId: '1',
|
||||
updatedAt: '2019-02-12T21:01:22.479Z',
|
||||
updatedBy: 'elastic',
|
||||
|
@ -517,6 +524,7 @@ describe('disable()', () => {
|
|||
schedule: { interval: '10s' },
|
||||
alertTypeId: 'myType',
|
||||
enabled: false,
|
||||
revision: 0,
|
||||
scheduledTaskId: null,
|
||||
updatedAt: '2019-02-12T21:01:22.479Z',
|
||||
updatedBy: 'elastic',
|
||||
|
@ -565,6 +573,7 @@ describe('disable()', () => {
|
|||
schedule: { interval: '10s' },
|
||||
alertTypeId: 'myType',
|
||||
enabled: false,
|
||||
revision: 0,
|
||||
scheduledTaskId: null,
|
||||
updatedAt: '2019-02-12T21:01:22.479Z',
|
||||
updatedBy: 'elastic',
|
||||
|
|
|
@ -189,6 +189,7 @@ describe('getAlertSummary()', () => {
|
|||
"lastRun": "2019-02-12T21:01:32.479Z",
|
||||
"muteAll": false,
|
||||
"name": "rule-name",
|
||||
"revision": 0,
|
||||
"ruleTypeId": "123",
|
||||
"status": "Active",
|
||||
"statusEndDate": "2019-02-12T21:01:22.479Z",
|
||||
|
|
|
@ -409,6 +409,7 @@ export const mockAAD = {
|
|||
execution: { uuid: 'c35db7cc-5bf7-46ea-b43f-b251613a5b72' },
|
||||
name: 'test-rule',
|
||||
producer: 'infrastructure',
|
||||
revision: 0,
|
||||
rule_type_id: 'metrics.alert.threshold',
|
||||
uuid: '0de91960-7643-11ed-b719-bb9db8582cb6',
|
||||
tags: [],
|
||||
|
|
|
@ -182,10 +182,10 @@ describe('transformActionParams', () => {
|
|||
flapping: false,
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"message": "Value \\"1\\" exists",
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"message": "Value \\"1\\" exists",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('alertName is passed to templates', () => {
|
||||
|
@ -212,10 +212,10 @@ describe('transformActionParams', () => {
|
|||
flapping: false,
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"message": "Value \\"alert-name\\" exists",
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"message": "Value \\"alert-name\\" exists",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('tags is passed to templates', () => {
|
||||
|
@ -242,10 +242,10 @@ describe('transformActionParams', () => {
|
|||
flapping: false,
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"message": "Value \\"tag-A,tag-B\\" exists",
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"message": "Value \\"tag-A,tag-B\\" exists",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('undefined tags is passed to templates', () => {
|
||||
|
@ -271,10 +271,10 @@ describe('transformActionParams', () => {
|
|||
flapping: false,
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"message": "Value \\"\\" is undefined and renders as empty string",
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"message": "Value \\"\\" is undefined and renders as empty string",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('empty tags is passed to templates', () => {
|
||||
|
@ -301,10 +301,10 @@ describe('transformActionParams', () => {
|
|||
flapping: false,
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"message": "Value \\"\\" is an empty array and renders as empty string",
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"message": "Value \\"\\" is an empty array and renders as empty string",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('spaceId is passed to templates', () => {
|
||||
|
@ -331,10 +331,10 @@ describe('transformActionParams', () => {
|
|||
flapping: false,
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"message": "Value \\"spaceId-A\\" exists",
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"message": "Value \\"spaceId-A\\" exists",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('alertInstanceId is passed to templates', () => {
|
||||
|
@ -361,10 +361,10 @@ describe('transformActionParams', () => {
|
|||
flapping: false,
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"message": "Value \\"2\\" exists",
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"message": "Value \\"2\\" exists",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('alertActionGroup is passed to templates', () => {
|
||||
|
@ -391,10 +391,10 @@ describe('transformActionParams', () => {
|
|||
flapping: false,
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"message": "Value \\"action-group\\" exists",
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"message": "Value \\"action-group\\" exists",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('alertActionGroupName is passed to templates', () => {
|
||||
|
@ -421,10 +421,10 @@ describe('transformActionParams', () => {
|
|||
flapping: false,
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"message": "Value \\"Action Group\\" exists",
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"message": "Value \\"Action Group\\" exists",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('rule variables are passed to templates', () => {
|
||||
|
@ -451,10 +451,10 @@ describe('transformActionParams', () => {
|
|||
flapping: false,
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"message": "Value \\"1\\", \\"alert-name\\", \\"spaceId-A\\" and \\"tag-A,tag-B\\" exist",
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"message": "Value \\"1\\", \\"alert-name\\", \\"spaceId-A\\" and \\"tag-A,tag-B\\" exist",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('rule alert variables are passed to templates', () => {
|
||||
|
@ -482,10 +482,10 @@ describe('transformActionParams', () => {
|
|||
flapping: false,
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"message": "Value \\"2\\", \\"action-group\\", \\"uuid-1\\" and \\"Action Group\\" exist",
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"message": "Value \\"2\\", \\"action-group\\", \\"uuid-1\\" and \\"Action Group\\" exist",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('date is passed to templates', () => {
|
||||
|
@ -613,10 +613,10 @@ describe('transformActionParams', () => {
|
|||
flapping: true,
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"message": "Value \\"true\\" exists",
|
||||
}
|
||||
`);
|
||||
Object {
|
||||
"message": "Value \\"true\\" exists",
|
||||
}
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -665,9 +665,9 @@ describe('transformSummaryActionParams', () => {
|
|||
|
||||
const result = transformSummaryActionParams({ ...params, actionParams });
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"message": "Value \\"{\\"@timestamp\\":\\"2022-12-07T15:38:43.472Z\\",\\"event\\":{\\"kind\\":\\"signal\\",\\"action\\":\\"active\\"},\\"kibana\\":{\\"version\\":\\"8.7.0\\",\\"space_ids\\":[\\"default\\"],\\"alert\\":{\\"instance\\":{\\"id\\":\\"*\\"},\\"uuid\\":\\"2d3e8fe5-3e8b-4361-916e-9eaab0bf2084\\",\\"status\\":\\"active\\",\\"workflow_status\\":\\"open\\",\\"reason\\":\\"system.cpu is 90% in the last 1 min for all hosts. Alert when > 50%.\\",\\"time_range\\":{\\"gte\\":\\"2022-01-01T12:00:00.000Z\\"},\\"start\\":\\"2022-12-07T15:23:13.488Z\\",\\"duration\\":{\\"us\\":100000},\\"flapping\\":false,\\"rule\\":{\\"category\\":\\"Metric threshold\\",\\"consumer\\":\\"alerts\\",\\"execution\\":{\\"uuid\\":\\"c35db7cc-5bf7-46ea-b43f-b251613a5b72\\"},\\"name\\":\\"test-rule\\",\\"producer\\":\\"infrastructure\\",\\"rule_type_id\\":\\"metrics.alert.threshold\\",\\"uuid\\":\\"0de91960-7643-11ed-b719-bb9db8582cb6\\",\\"tags\\":[]}}}}\\", \\"http://ruleurl\\" and \\"{\\"foo\\":\\"bar\\",\\"foo_bar\\":true,\\"name\\":\\"test-rule\\",\\"id\\":\\"1\\"}\\" exist",
|
||||
}
|
||||
Object {
|
||||
"message": "Value \\"{\\"@timestamp\\":\\"2022-12-07T15:38:43.472Z\\",\\"event\\":{\\"kind\\":\\"signal\\",\\"action\\":\\"active\\"},\\"kibana\\":{\\"version\\":\\"8.7.0\\",\\"space_ids\\":[\\"default\\"],\\"alert\\":{\\"instance\\":{\\"id\\":\\"*\\"},\\"uuid\\":\\"2d3e8fe5-3e8b-4361-916e-9eaab0bf2084\\",\\"status\\":\\"active\\",\\"workflow_status\\":\\"open\\",\\"reason\\":\\"system.cpu is 90% in the last 1 min for all hosts. Alert when > 50%.\\",\\"time_range\\":{\\"gte\\":\\"2022-01-01T12:00:00.000Z\\"},\\"start\\":\\"2022-12-07T15:23:13.488Z\\",\\"duration\\":{\\"us\\":100000},\\"flapping\\":false,\\"rule\\":{\\"category\\":\\"Metric threshold\\",\\"consumer\\":\\"alerts\\",\\"execution\\":{\\"uuid\\":\\"c35db7cc-5bf7-46ea-b43f-b251613a5b72\\"},\\"name\\":\\"test-rule\\",\\"producer\\":\\"infrastructure\\",\\"revision\\":0,\\"rule_type_id\\":\\"metrics.alert.threshold\\",\\"uuid\\":\\"0de91960-7643-11ed-b719-bb9db8582cb6\\",\\"tags\\":[]}}}}\\", \\"http://ruleurl\\" and \\"{\\"foo\\":\\"bar\\",\\"foo_bar\\":true,\\"name\\":\\"test-rule\\",\\"id\\":\\"1\\"}\\" exist",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
|
|
|
@ -398,6 +398,9 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"revision": {
|
||||
"type": "long"
|
||||
},
|
||||
"rule_type_id": {
|
||||
"type": "keyword",
|
||||
"ignore_above": 1024
|
||||
|
|
|
@ -178,6 +178,7 @@ export const EventSchema = schema.maybe(
|
|||
),
|
||||
})
|
||||
),
|
||||
revision: ecsStringOrNumber(),
|
||||
rule_type_id: ecsString(),
|
||||
})
|
||||
),
|
||||
|
|
|
@ -177,6 +177,9 @@ exports.EcsCustomPropertyMappings = {
|
|||
},
|
||||
},
|
||||
},
|
||||
revision: {
|
||||
type: 'long',
|
||||
},
|
||||
rule_type_id: {
|
||||
type: 'keyword',
|
||||
ignore_above: 1024,
|
||||
|
|
|
@ -40,6 +40,7 @@ const ruleExecutionLogForExecutorsMock = {
|
|||
ruleId: context.ruleId ?? 'some rule id',
|
||||
ruleUuid: context.ruleUuid ?? 'some rule uuid',
|
||||
ruleName: context.ruleName ?? 'Some rule',
|
||||
ruleRevision: context.ruleRevision ?? 0,
|
||||
ruleType: context.ruleType ?? 'some rule type',
|
||||
spaceId: context.spaceId ?? 'some space id',
|
||||
},
|
||||
|
|
|
@ -50,7 +50,7 @@ export const createClientForExecutors = (
|
|||
const baseLogSuffix = baseCorrelationIds.getLogSuffix();
|
||||
const baseLogMeta = baseCorrelationIds.getLogMeta();
|
||||
|
||||
const { executionId, ruleId, ruleUuid, ruleName, ruleType, spaceId } = context;
|
||||
const { executionId, ruleId, ruleUuid, ruleName, ruleRevision, ruleType, spaceId } = context;
|
||||
|
||||
const client: IRuleExecutionLogForExecutors = {
|
||||
get context() {
|
||||
|
@ -140,6 +140,7 @@ export const createClientForExecutors = (
|
|||
ruleId,
|
||||
ruleUuid,
|
||||
ruleName,
|
||||
ruleRevision,
|
||||
ruleType,
|
||||
spaceId,
|
||||
executionId,
|
||||
|
@ -202,6 +203,7 @@ export const createClientForExecutors = (
|
|||
ruleId,
|
||||
ruleUuid,
|
||||
ruleName,
|
||||
ruleRevision,
|
||||
ruleType,
|
||||
spaceId,
|
||||
executionId,
|
||||
|
@ -213,6 +215,7 @@ export const createClientForExecutors = (
|
|||
ruleId,
|
||||
ruleUuid,
|
||||
ruleName,
|
||||
ruleRevision,
|
||||
ruleType,
|
||||
spaceId,
|
||||
executionId,
|
||||
|
|
|
@ -92,6 +92,11 @@ export interface RuleExecutionContext {
|
|||
*/
|
||||
ruleName: string;
|
||||
|
||||
/**
|
||||
* Current revision of the rule being execution (rule.revision)
|
||||
*/
|
||||
ruleRevision: number;
|
||||
|
||||
/**
|
||||
* Alerting Framework's rule type id of the rule being executed.
|
||||
*/
|
||||
|
|
|
@ -31,6 +31,7 @@ export interface BaseArgs {
|
|||
ruleId: string;
|
||||
ruleUuid: string;
|
||||
ruleName: string;
|
||||
ruleRevision: number;
|
||||
ruleType: string;
|
||||
spaceId: string;
|
||||
executionId: string;
|
||||
|
@ -83,6 +84,7 @@ export const createEventLogWriter = (eventLogService: IEventLogService): IEventL
|
|||
execution: {
|
||||
uuid: args.executionId,
|
||||
},
|
||||
revision: args.ruleRevision,
|
||||
},
|
||||
},
|
||||
space_ids: [args.spaceId],
|
||||
|
@ -126,6 +128,7 @@ export const createEventLogWriter = (eventLogService: IEventLogService): IEventL
|
|||
status: args.newStatus,
|
||||
status_order: ruleExecutionStatusToNumber(args.newStatus),
|
||||
},
|
||||
revision: args.ruleRevision,
|
||||
},
|
||||
},
|
||||
space_ids: [args.spaceId],
|
||||
|
@ -167,6 +170,7 @@ export const createEventLogWriter = (eventLogService: IEventLogService): IEventL
|
|||
uuid: args.executionId,
|
||||
metrics: args.metrics,
|
||||
},
|
||||
revision: args.ruleRevision,
|
||||
},
|
||||
},
|
||||
space_ids: [args.spaceId],
|
||||
|
|
|
@ -213,10 +213,10 @@ export const getRuleConfigMock = (type: string = 'rule-type'): SanitizedRuleConf
|
|||
consumer: 'sample consumer',
|
||||
notifyWhen: null,
|
||||
producer: 'sample producer',
|
||||
revision: 0,
|
||||
ruleTypeId: `${type}-id`,
|
||||
ruleTypeName: type,
|
||||
muteAll: false,
|
||||
revision: 0,
|
||||
snoozeSchedule: [],
|
||||
});
|
||||
|
||||
|
|
|
@ -124,6 +124,7 @@ export const createSecurityRuleTypeWrapper: CreateSecurityRuleTypeWrapper =
|
|||
ruleId: rule.id,
|
||||
ruleUuid: params.ruleId,
|
||||
ruleName: rule.name,
|
||||
ruleRevision: rule.revision,
|
||||
ruleType: rule.ruleTypeId,
|
||||
spaceId,
|
||||
},
|
||||
|
|
|
@ -713,10 +713,10 @@ async function invokeExecutor({
|
|||
tags: [],
|
||||
consumer: '',
|
||||
producer: '',
|
||||
revision: 0,
|
||||
ruleTypeId: '',
|
||||
ruleTypeName: '',
|
||||
enabled: true,
|
||||
revision: 0,
|
||||
schedule: {
|
||||
interval: '1h',
|
||||
},
|
||||
|
|
|
@ -203,10 +203,10 @@ describe('ruleType', () => {
|
|||
tags: [],
|
||||
consumer: '',
|
||||
producer: '',
|
||||
revision: 0,
|
||||
ruleTypeId: '',
|
||||
ruleTypeName: '',
|
||||
enabled: true,
|
||||
revision: 0,
|
||||
schedule: {
|
||||
interval: '1h',
|
||||
},
|
||||
|
@ -270,10 +270,10 @@ describe('ruleType', () => {
|
|||
tags: [],
|
||||
consumer: '',
|
||||
producer: '',
|
||||
revision: 0,
|
||||
ruleTypeId: '',
|
||||
ruleTypeName: '',
|
||||
enabled: true,
|
||||
revision: 0,
|
||||
schedule: {
|
||||
interval: '1h',
|
||||
},
|
||||
|
@ -337,10 +337,10 @@ describe('ruleType', () => {
|
|||
tags: [],
|
||||
consumer: '',
|
||||
producer: '',
|
||||
revision: 0,
|
||||
ruleTypeId: '',
|
||||
ruleTypeName: '',
|
||||
enabled: true,
|
||||
revision: 0,
|
||||
schedule: {
|
||||
interval: '1h',
|
||||
},
|
||||
|
@ -403,10 +403,10 @@ describe('ruleType', () => {
|
|||
tags: [],
|
||||
consumer: '',
|
||||
producer: '',
|
||||
revision: 0,
|
||||
ruleTypeId: '',
|
||||
ruleTypeName: '',
|
||||
enabled: true,
|
||||
revision: 0,
|
||||
schedule: {
|
||||
interval: '1h',
|
||||
},
|
||||
|
|
|
@ -28,6 +28,7 @@ describe('loadRuleSummary', () => {
|
|||
lastRun: '2021-04-01T22:18:27.609Z',
|
||||
muteAll: false,
|
||||
name: 'test',
|
||||
revision: 0,
|
||||
ruleTypeId: '.index-threshold',
|
||||
status: 'OK',
|
||||
statusEndDate: '2021-04-01T22:19:25.174Z',
|
||||
|
@ -55,6 +56,7 @@ describe('loadRuleSummary', () => {
|
|||
last_run: '2021-04-01T22:18:27.609Z',
|
||||
mute_all: false,
|
||||
name: 'test',
|
||||
revision: 0,
|
||||
rule_type_id: '.index-threshold',
|
||||
status: 'OK',
|
||||
status_end_date: '2021-04-01T22:19:25.174Z',
|
||||
|
|
|
@ -481,6 +481,7 @@ function mockRuleSummary(overloads: Partial<RuleSummary> = {}): RuleSummary {
|
|||
throttle: '',
|
||||
enabled: true,
|
||||
errorMessages: [],
|
||||
revision: 0,
|
||||
statusStartDate: fake2MinutesAgo.toISOString(),
|
||||
statusEndDate: fakeNow.toISOString(),
|
||||
alerts: {
|
||||
|
|
|
@ -162,6 +162,7 @@ function mockRuleSummary(overloads: Partial<any> = {}): any {
|
|||
throttle: null,
|
||||
enabled: true,
|
||||
errorMessages: [],
|
||||
revision: 0,
|
||||
statusStartDate: fake2MinutesAgo.toISOString(),
|
||||
statusEndDate: fakeNow.toISOString(),
|
||||
alerts: {
|
||||
|
|
|
@ -95,6 +95,7 @@ export function mockRuleSummary(overloads: Partial<RuleSummary> = {}): RuleSumma
|
|||
throttle: '',
|
||||
enabled: true,
|
||||
errorMessages: [],
|
||||
revision: 0,
|
||||
statusStartDate: '2022-03-21T07:40:46-07:00',
|
||||
statusEndDate: '2022-03-25T07:40:46-07:00',
|
||||
alerts: {
|
||||
|
|
|
@ -78,6 +78,7 @@ export default function createGetAlertSummaryTests({ getService }: FtrProviderCo
|
|||
expect(stableBody).to.eql({
|
||||
name: 'abc',
|
||||
tags: ['foo'],
|
||||
revision: 0,
|
||||
rule_type_id: 'test.noop',
|
||||
consumer: 'alertsFixture',
|
||||
status: 'OK',
|
||||
|
|
|
@ -68,6 +68,7 @@ export default function createGetAlertSummaryTests({ getService }: FtrProviderCo
|
|||
id: createdRule.id,
|
||||
name: 'abc',
|
||||
tags: ['foo'],
|
||||
revision: 0,
|
||||
rule_type_id: 'test.noop',
|
||||
consumer: 'alertsFixture',
|
||||
status: 'OK',
|
||||
|
@ -106,6 +107,7 @@ export default function createGetAlertSummaryTests({ getService }: FtrProviderCo
|
|||
id: createdRule.id,
|
||||
name: 'abc',
|
||||
tags: ['foo'],
|
||||
revision: 0,
|
||||
rule_type_id: 'test.noop',
|
||||
consumer: 'alertsFixture',
|
||||
status: 'OK',
|
||||
|
|
|
@ -163,6 +163,7 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
execution_gap_duration_s: 3000,
|
||||
},
|
||||
},
|
||||
revision: 0,
|
||||
},
|
||||
},
|
||||
alerting: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue