Skip to content

Commit 6813fa9

Browse files
committed
Merge branch 'master' into alerting/deleted-alert-error
* master: [Event Log] Adds namespace into save objects (#62974)
2 parents c50ec7d + 1f732ad commit 6813fa9

File tree

11 files changed

+25
-38
lines changed

11 files changed

+25
-38
lines changed

x-pack/plugins/actions/server/lib/action_executor.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ export class ActionExecutor {
7575
} = this.actionExecutorContext!;
7676

7777
const services = getServices(request);
78-
const namespace = spaces && spaces.getSpaceId(request);
78+
const spaceId = spaces && spaces.getSpaceId(request);
79+
const namespace = spaceId && spaceId !== 'default' ? { namespace: spaceId } : {};
7980

8081
// Ensure user can read the action before processing
8182
const {
@@ -91,9 +92,7 @@ export class ActionExecutor {
9192
} = await encryptedSavedObjectsPlugin.getDecryptedAsInternalUser<RawAction>(
9293
'action',
9394
actionId,
94-
{
95-
namespace: namespace === 'default' ? undefined : namespace,
96-
}
95+
namespace
9796
);
9897
const actionType = actionTypeRegistry.get(actionTypeId);
9998

@@ -112,7 +111,7 @@ export class ActionExecutor {
112111
const actionLabel = `${actionTypeId}:${actionId}: ${name}`;
113112
const event: IEvent = {
114113
event: { action: EVENT_LOG_ACTIONS.execute },
115-
kibana: { namespace, saved_objects: [{ type: 'action', id: actionId }] },
114+
kibana: { saved_objects: [{ type: 'action', id: actionId, ...namespace }] },
116115
};
117116

118117
eventLogger.startTiming(event);

x-pack/plugins/alerting/server/task_runner/create_execution_handler.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ test('calls actionsPlugin.execute per selected action', async () => {
9191
"alerting": Object {
9292
"instance_id": "2",
9393
},
94-
"namespace": "default",
9594
"saved_objects": Array [
9695
Object {
9796
"id": "1",

x-pack/plugins/alerting/server/task_runner/create_execution_handler.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,17 @@ export function createExecutionHandler({
8787
apiKey,
8888
});
8989

90+
const namespace = spaceId === 'default' ? {} : { namespace: spaceId };
91+
9092
const event: IEvent = {
9193
event: { action: EVENT_LOG_ACTIONS.executeAction },
9294
kibana: {
9395
alerting: {
9496
instance_id: alertInstanceId,
9597
},
96-
namespace: spaceId,
9798
saved_objects: [
98-
{ type: 'alert', id: alertId },
99-
{ type: 'action', id: action.id },
99+
{ type: 'alert', id: alertId, ...namespace },
100+
{ type: 'action', id: action.id, ...namespace },
100101
],
101102
},
102103
};

x-pack/plugins/alerting/server/task_runner/task_runner.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ describe('Task Runner', () => {
170170
"action": "execute",
171171
},
172172
"kibana": Object {
173-
"namespace": undefined,
174173
"saved_objects": Array [
175174
Object {
176175
"id": "1",
176+
"namespace": undefined,
177177
"type": "alert",
178178
},
179179
],
@@ -230,10 +230,10 @@ describe('Task Runner', () => {
230230
"action": "execute",
231231
},
232232
"kibana": Object {
233-
"namespace": undefined,
234233
"saved_objects": Array [
235234
Object {
236235
"id": "1",
236+
"namespace": undefined,
237237
"type": "alert",
238238
},
239239
],
@@ -250,10 +250,10 @@ describe('Task Runner', () => {
250250
"alerting": Object {
251251
"instance_id": "1",
252252
},
253-
"namespace": undefined,
254253
"saved_objects": Array [
255254
Object {
256255
"id": "1",
256+
"namespace": undefined,
257257
"type": "alert",
258258
},
259259
],
@@ -270,14 +270,15 @@ describe('Task Runner', () => {
270270
"alerting": Object {
271271
"instance_id": "1",
272272
},
273-
"namespace": undefined,
274273
"saved_objects": Array [
275274
Object {
276275
"id": "1",
276+
"namespace": undefined,
277277
"type": "alert",
278278
},
279279
Object {
280280
"id": "1",
281+
"namespace": undefined,
281282
"type": "action",
282283
},
283284
],
@@ -345,10 +346,10 @@ describe('Task Runner', () => {
345346
"action": "execute",
346347
},
347348
"kibana": Object {
348-
"namespace": undefined,
349349
"saved_objects": Array [
350350
Object {
351351
"id": "1",
352+
"namespace": undefined,
352353
"type": "alert",
353354
},
354355
],
@@ -365,10 +366,10 @@ describe('Task Runner', () => {
365366
"alerting": Object {
366367
"instance_id": "2",
367368
},
368-
"namespace": undefined,
369369
"saved_objects": Array [
370370
Object {
371371
"id": "1",
372+
"namespace": undefined,
372373
"type": "alert",
373374
},
374375
],
@@ -561,10 +562,10 @@ describe('Task Runner', () => {
561562
"action": "execute",
562563
},
563564
"kibana": Object {
564-
"namespace": undefined,
565565
"saved_objects": Array [
566566
Object {
567567
"id": "1",
568+
"namespace": undefined,
568569
"type": "alert",
569570
},
570571
],

x-pack/plugins/alerting/server/task_runner/task_runner.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export class TaskRunner {
174174
const alertLabel = `${this.alertType.id}:${alertId}: '${name}'`;
175175
const event: IEvent = {
176176
event: { action: EVENT_LOG_ACTIONS.execute },
177-
kibana: { namespace, saved_objects: [{ type: 'alert', id: alertId }] },
177+
kibana: { saved_objects: [{ type: 'alert', id: alertId, namespace }] },
178178
};
179179
eventLogger.startTiming(event);
180180

@@ -386,11 +386,10 @@ function generateNewAndResolvedInstanceEvents(params: GenerateNewAndResolvedInst
386386
action,
387387
},
388388
kibana: {
389-
namespace: params.namespace,
390389
alerting: {
391390
instance_id: id,
392391
},
393-
saved_objects: [{ type: 'alert', id: params.alertId }],
392+
saved_objects: [{ type: 'alert', id: params.alertId, namespace: params.namespace }],
394393
},
395394
message,
396395
};

x-pack/plugins/event_log/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ Here's the event written to the event log index:
125125
"duration": 1000000
126126
},
127127
"kibana": {
128-
"namespace": "default",
129128
"saved_objects": [
130129
{
131130
"type": "action",

x-pack/plugins/event_log/generated/mappings.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@
7272
"type": "keyword",
7373
"ignore_above": 1024
7474
},
75-
"namespace": {
76-
"type": "keyword",
77-
"ignore_above": 1024
78-
},
7975
"alerting": {
8076
"properties": {
8177
"instance_id": {
@@ -86,7 +82,7 @@
8682
},
8783
"saved_objects": {
8884
"properties": {
89-
"store": {
85+
"namespace": {
9086
"type": "keyword",
9187
"ignore_above": 1024
9288
},

x-pack/plugins/event_log/generated/schemas.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ export const EventSchema = schema.maybe(
5656
kibana: schema.maybe(
5757
schema.object({
5858
server_uuid: ecsString(),
59-
namespace: ecsString(),
6059
alerting: schema.maybe(
6160
schema.object({
6261
instance_id: ecsString(),
@@ -65,7 +64,7 @@ export const EventSchema = schema.maybe(
6564
saved_objects: schema.maybe(
6665
schema.arrayOf(
6766
schema.object({
68-
store: ecsString(),
67+
namespace: ecsString(),
6968
id: ecsString(),
7069
type: ecsString(),
7170
})

x-pack/plugins/event_log/scripts/mappings.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,12 @@ exports.EcsKibanaExtensionsMappings = {
2020
},
2121
},
2222
},
23-
// relevant kibana space
24-
namespace: {
25-
type: 'keyword',
26-
ignore_above: 1024,
27-
},
2823
// array of saved object references, for "linking" via search
2924
saved_objects: {
3025
type: 'nested',
3126
properties: {
32-
// 'kibana' for typical saved object, 'task_manager' for TM, etc
33-
store: {
27+
// relevant kibana space
28+
namespace: {
3429
type: 'keyword',
3530
ignore_above: 1024,
3631
},
@@ -61,9 +56,8 @@ exports.EcsEventLogProperties = [
6156
'error.message',
6257
'user.name',
6358
'kibana.server_uuid',
64-
'kibana.namespace',
6559
'kibana.alerting.instance_id',
66-
'kibana.saved_objects.store',
60+
'kibana.saved_objects.namespace',
6761
'kibana.saved_objects.id',
6862
'kibana.saved_objects.name',
6963
'kibana.saved_objects.type',

x-pack/plugins/event_log/server/routes/_mock_handler_arguments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ export function fakeEvent(overrides = {}) {
5050
duration: 1000000,
5151
},
5252
kibana: {
53-
namespace: 'default',
5453
saved_objects: [
5554
{
55+
namespace: 'default',
5656
type: 'action',
5757
id: '968f1b82-0414-4a10-becc-56b6473e4a29',
5858
},

0 commit comments

Comments
 (0)