[Event Log] Adds namespace into save objects (#62974)
Adds a namespace attribute to the saved object object within the Event Log so that each Saved Object can have its own. This change also removes the existing kibana.namespace field. As Event Log is not yet in use, this does not include a migration.
This commit is contained in:
parent
f44d951300
commit
1f732ad29a
|
@ -75,7 +75,8 @@ export class ActionExecutor {
|
|||
} = this.actionExecutorContext!;
|
||||
|
||||
const services = getServices(request);
|
||||
const namespace = spaces && spaces.getSpaceId(request);
|
||||
const spaceId = spaces && spaces.getSpaceId(request);
|
||||
const namespace = spaceId && spaceId !== 'default' ? { namespace: spaceId } : {};
|
||||
|
||||
// Ensure user can read the action before processing
|
||||
const {
|
||||
|
@ -91,9 +92,7 @@ export class ActionExecutor {
|
|||
} = await encryptedSavedObjectsPlugin.getDecryptedAsInternalUser<RawAction>(
|
||||
'action',
|
||||
actionId,
|
||||
{
|
||||
namespace: namespace === 'default' ? undefined : namespace,
|
||||
}
|
||||
namespace
|
||||
);
|
||||
const actionType = actionTypeRegistry.get(actionTypeId);
|
||||
|
||||
|
@ -112,7 +111,7 @@ export class ActionExecutor {
|
|||
const actionLabel = `${actionTypeId}:${actionId}: ${name}`;
|
||||
const event: IEvent = {
|
||||
event: { action: EVENT_LOG_ACTIONS.execute },
|
||||
kibana: { namespace, saved_objects: [{ type: 'action', id: actionId }] },
|
||||
kibana: { saved_objects: [{ type: 'action', id: actionId, ...namespace }] },
|
||||
};
|
||||
|
||||
eventLogger.startTiming(event);
|
||||
|
|
|
@ -91,7 +91,6 @@ test('calls actionsPlugin.execute per selected action', async () => {
|
|||
"alerting": Object {
|
||||
"instance_id": "2",
|
||||
},
|
||||
"namespace": "default",
|
||||
"saved_objects": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
|
|
|
@ -87,16 +87,17 @@ export function createExecutionHandler({
|
|||
apiKey,
|
||||
});
|
||||
|
||||
const namespace = spaceId === 'default' ? {} : { namespace: spaceId };
|
||||
|
||||
const event: IEvent = {
|
||||
event: { action: EVENT_LOG_ACTIONS.executeAction },
|
||||
kibana: {
|
||||
alerting: {
|
||||
instance_id: alertInstanceId,
|
||||
},
|
||||
namespace: spaceId,
|
||||
saved_objects: [
|
||||
{ type: 'alert', id: alertId },
|
||||
{ type: 'action', id: action.id },
|
||||
{ type: 'alert', id: alertId, ...namespace },
|
||||
{ type: 'action', id: action.id, ...namespace },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
|
@ -169,10 +169,10 @@ describe('Task Runner', () => {
|
|||
"action": "execute",
|
||||
},
|
||||
"kibana": Object {
|
||||
"namespace": undefined,
|
||||
"saved_objects": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"namespace": undefined,
|
||||
"type": "alert",
|
||||
},
|
||||
],
|
||||
|
@ -229,10 +229,10 @@ describe('Task Runner', () => {
|
|||
"action": "execute",
|
||||
},
|
||||
"kibana": Object {
|
||||
"namespace": undefined,
|
||||
"saved_objects": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"namespace": undefined,
|
||||
"type": "alert",
|
||||
},
|
||||
],
|
||||
|
@ -249,10 +249,10 @@ describe('Task Runner', () => {
|
|||
"alerting": Object {
|
||||
"instance_id": "1",
|
||||
},
|
||||
"namespace": undefined,
|
||||
"saved_objects": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"namespace": undefined,
|
||||
"type": "alert",
|
||||
},
|
||||
],
|
||||
|
@ -269,14 +269,15 @@ describe('Task Runner', () => {
|
|||
"alerting": Object {
|
||||
"instance_id": "1",
|
||||
},
|
||||
"namespace": undefined,
|
||||
"saved_objects": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"namespace": undefined,
|
||||
"type": "alert",
|
||||
},
|
||||
Object {
|
||||
"id": "1",
|
||||
"namespace": undefined,
|
||||
"type": "action",
|
||||
},
|
||||
],
|
||||
|
@ -344,10 +345,10 @@ describe('Task Runner', () => {
|
|||
"action": "execute",
|
||||
},
|
||||
"kibana": Object {
|
||||
"namespace": undefined,
|
||||
"saved_objects": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"namespace": undefined,
|
||||
"type": "alert",
|
||||
},
|
||||
],
|
||||
|
@ -364,10 +365,10 @@ describe('Task Runner', () => {
|
|||
"alerting": Object {
|
||||
"instance_id": "2",
|
||||
},
|
||||
"namespace": undefined,
|
||||
"saved_objects": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"namespace": undefined,
|
||||
"type": "alert",
|
||||
},
|
||||
],
|
||||
|
@ -560,10 +561,10 @@ describe('Task Runner', () => {
|
|||
"action": "execute",
|
||||
},
|
||||
"kibana": Object {
|
||||
"namespace": undefined,
|
||||
"saved_objects": Array [
|
||||
Object {
|
||||
"id": "1",
|
||||
"namespace": undefined,
|
||||
"type": "alert",
|
||||
},
|
||||
],
|
||||
|
|
|
@ -173,7 +173,7 @@ export class TaskRunner {
|
|||
const alertLabel = `${this.alertType.id}:${alertId}: '${name}'`;
|
||||
const event: IEvent = {
|
||||
event: { action: EVENT_LOG_ACTIONS.execute },
|
||||
kibana: { namespace, saved_objects: [{ type: 'alert', id: alertId }] },
|
||||
kibana: { saved_objects: [{ type: 'alert', id: alertId, namespace }] },
|
||||
};
|
||||
eventLogger.startTiming(event);
|
||||
|
||||
|
@ -378,11 +378,10 @@ function generateNewAndResolvedInstanceEvents(params: GenerateNewAndResolvedInst
|
|||
action,
|
||||
},
|
||||
kibana: {
|
||||
namespace: params.namespace,
|
||||
alerting: {
|
||||
instance_id: id,
|
||||
},
|
||||
saved_objects: [{ type: 'alert', id: params.alertId }],
|
||||
saved_objects: [{ type: 'alert', id: params.alertId, namespace: params.namespace }],
|
||||
},
|
||||
message,
|
||||
};
|
||||
|
|
|
@ -125,7 +125,6 @@ Here's the event written to the event log index:
|
|||
"duration": 1000000
|
||||
},
|
||||
"kibana": {
|
||||
"namespace": "default",
|
||||
"saved_objects": [
|
||||
{
|
||||
"type": "action",
|
||||
|
|
|
@ -72,10 +72,6 @@
|
|||
"type": "keyword",
|
||||
"ignore_above": 1024
|
||||
},
|
||||
"namespace": {
|
||||
"type": "keyword",
|
||||
"ignore_above": 1024
|
||||
},
|
||||
"alerting": {
|
||||
"properties": {
|
||||
"instance_id": {
|
||||
|
@ -86,7 +82,7 @@
|
|||
},
|
||||
"saved_objects": {
|
||||
"properties": {
|
||||
"store": {
|
||||
"namespace": {
|
||||
"type": "keyword",
|
||||
"ignore_above": 1024
|
||||
},
|
||||
|
|
|
@ -56,7 +56,6 @@ export const EventSchema = schema.maybe(
|
|||
kibana: schema.maybe(
|
||||
schema.object({
|
||||
server_uuid: ecsString(),
|
||||
namespace: ecsString(),
|
||||
alerting: schema.maybe(
|
||||
schema.object({
|
||||
instance_id: ecsString(),
|
||||
|
@ -65,7 +64,7 @@ export const EventSchema = schema.maybe(
|
|||
saved_objects: schema.maybe(
|
||||
schema.arrayOf(
|
||||
schema.object({
|
||||
store: ecsString(),
|
||||
namespace: ecsString(),
|
||||
id: ecsString(),
|
||||
type: ecsString(),
|
||||
})
|
||||
|
|
|
@ -20,17 +20,12 @@ exports.EcsKibanaExtensionsMappings = {
|
|||
},
|
||||
},
|
||||
},
|
||||
// relevant kibana space
|
||||
namespace: {
|
||||
type: 'keyword',
|
||||
ignore_above: 1024,
|
||||
},
|
||||
// array of saved object references, for "linking" via search
|
||||
saved_objects: {
|
||||
type: 'nested',
|
||||
properties: {
|
||||
// 'kibana' for typical saved object, 'task_manager' for TM, etc
|
||||
store: {
|
||||
// relevant kibana space
|
||||
namespace: {
|
||||
type: 'keyword',
|
||||
ignore_above: 1024,
|
||||
},
|
||||
|
@ -61,9 +56,8 @@ exports.EcsEventLogProperties = [
|
|||
'error.message',
|
||||
'user.name',
|
||||
'kibana.server_uuid',
|
||||
'kibana.namespace',
|
||||
'kibana.alerting.instance_id',
|
||||
'kibana.saved_objects.store',
|
||||
'kibana.saved_objects.namespace',
|
||||
'kibana.saved_objects.id',
|
||||
'kibana.saved_objects.name',
|
||||
'kibana.saved_objects.type',
|
||||
|
|
|
@ -50,9 +50,9 @@ export function fakeEvent(overrides = {}) {
|
|||
duration: 1000000,
|
||||
},
|
||||
kibana: {
|
||||
namespace: 'default',
|
||||
saved_objects: [
|
||||
{
|
||||
namespace: 'default',
|
||||
type: 'action',
|
||||
id: '968f1b82-0414-4a10-becc-56b6473e4a29',
|
||||
},
|
||||
|
|
|
@ -220,9 +220,9 @@ export default function({ getService }: FtrProviderContext) {
|
|||
duration: 1000000,
|
||||
},
|
||||
kibana: {
|
||||
namespace: 'default',
|
||||
saved_objects: [
|
||||
{
|
||||
namespace: 'default',
|
||||
type: 'event_log_test',
|
||||
id,
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue