diff --git a/x-pack/platform/plugins/private/reporting/server/lib/store/scheduled_report.test.ts b/x-pack/platform/plugins/private/reporting/server/lib/store/scheduled_report.test.ts index 9210ed4c55d80..4f4778032dfce 100644 --- a/x-pack/platform/plugins/private/reporting/server/lib/store/scheduled_report.test.ts +++ b/x-pack/platform/plugins/private/reporting/server/lib/store/scheduled_report.test.ts @@ -22,6 +22,7 @@ test('ScheduledReport should return correctly formatted outputs', () => { kibanaId: 'instance-uuid', kibanaName: 'kibana', queueTimeout: 120000, + spaceId: 'a-space', scheduledReport: { id: 'report-so-id-111', attributes: { @@ -81,6 +82,7 @@ test('ScheduledReport should return correctly formatted outputs', () => { version: '8.0.0', }, scheduled_report_id: 'report-so-id-111', + space_id: 'a-space', status: 'processing', started_at: expect.any(String), process_expiration: expect.any(String), @@ -103,6 +105,7 @@ test('ScheduledReport should return correctly formatted outputs', () => { status: 'processing', attempts: 1, started_at: expect.any(String), + space_id: 'a-space', migration_version: '7.14.0', output: {}, queue_time_ms: expect.any(Number), @@ -140,6 +143,7 @@ test('ScheduledReport should throw an error if report payload is malformed', () references: [], type: 'scheduled-report', }, + spaceId: 'another-space', }); }; expect(createInstance).toThrowErrorMatchingInlineSnapshot( @@ -154,6 +158,7 @@ test('ScheduledReport should throw an error if scheduled_report saved object is kibanaId: 'instance-uuid', kibanaName: 'kibana', queueTimeout: 120000, + spaceId: 'another-space', // @ts-expect-error - missing id scheduledReport: { attributes: { diff --git a/x-pack/platform/plugins/private/reporting/server/lib/store/scheduled_report.ts b/x-pack/platform/plugins/private/reporting/server/lib/store/scheduled_report.ts index bfd2cbde1727c..bd3a95e9b6e15 100644 --- a/x-pack/platform/plugins/private/reporting/server/lib/store/scheduled_report.ts +++ b/x-pack/platform/plugins/private/reporting/server/lib/store/scheduled_report.ts @@ -18,6 +18,7 @@ interface ConstructorOpts { kibanaId: string; kibanaName: string; queueTimeout: number; + spaceId: string; scheduledReport: SavedObject; } @@ -26,7 +27,7 @@ export class ScheduledReport extends Report { * Create a report from a scheduled_report saved object */ constructor(opts: ConstructorOpts) { - const { kibanaId, kibanaName, runAt, scheduledReport, queueTimeout } = opts; + const { kibanaId, kibanaName, runAt, scheduledReport, spaceId, queueTimeout } = opts; const now = moment.utc(); const startTime = now.toISOString(); const expirationTime = now.add(queueTimeout).toISOString(); @@ -62,6 +63,7 @@ export class ScheduledReport extends Report { started_at: startTime, timeout: queueTimeout, scheduled_report_id: scheduledReport.id, + space_id: spaceId, }, { queue_time_ms: [now.diff(moment.utc(runAt), 'milliseconds')] } ); diff --git a/x-pack/platform/plugins/private/reporting/server/lib/tasks/run_scheduled_report.test.ts b/x-pack/platform/plugins/private/reporting/server/lib/tasks/run_scheduled_report.test.ts index f1b2f70dde607..ca1106bd09230 100644 --- a/x-pack/platform/plugins/private/reporting/server/lib/tasks/run_scheduled_report.test.ts +++ b/x-pack/platform/plugins/private/reporting/server/lib/tasks/run_scheduled_report.test.ts @@ -337,6 +337,7 @@ describe('Run Scheduled Report Task', () => { kibana_name: 'kibana', kibana_id: 'instance-uuid', started_at: expect.any(String), + space_id: 'default', timeout: 120000, max_attempts: 1, process_expiration: expect.any(String), diff --git a/x-pack/platform/plugins/private/reporting/server/lib/tasks/run_scheduled_report.ts b/x-pack/platform/plugins/private/reporting/server/lib/tasks/run_scheduled_report.ts index 9452407be1342..f2316c8098646 100644 --- a/x-pack/platform/plugins/private/reporting/server/lib/tasks/run_scheduled_report.ts +++ b/x-pack/platform/plugins/private/reporting/server/lib/tasks/run_scheduled_report.ts @@ -66,6 +66,7 @@ export class RunScheduledReportTask extends RunReportTask