Skip to content

Commit 106c69d

Browse files
kibanamachineymao1elasticmachine
authored
[8.19] [Response Ops][Reporting] Store space_id in report doc generated from scheduled export (#225669) (#226171)
# Backport This will backport the following commits from `main` to `8.19`: - [[Response Ops][Reporting] Store `space_id` in report doc generated from scheduled export (#225669)](#225669) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Ying Mao","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-07-02T11:33:53Z","message":"[Response Ops][Reporting] Store `space_id` in report doc generated from scheduled export (#225669)\n\n## Summary\n\nNoticed during verification that the report document generated during\nscheduled exports do not include the `space_id` field. We added it for\nsingle exports in [this\nPR](#221375) but forgot to update\nthe scheduled export feature to pass through the space ID.\n\n## To Verify\n\n1. Create a scheduled export and wait for it to generate a report\n2. Look for the doc in `.kibana-reporting`. It should contain the\n`space_id` field.\n\nCo-authored-by: Elastic Machine <[email protected]>","sha":"d43d90094aa2c6902624ccccd1c199f73fbfe9de","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:ResponseOps","Feature:Reporting:Framework","backport:version","v9.1.0","v8.19.0","v9.2.0"],"title":"[Response Ops][Reporting] Store `space_id` in report doc generated from scheduled export","number":225669,"url":"https://github.com/elastic/kibana/pull/225669","mergeCommit":{"message":"[Response Ops][Reporting] Store `space_id` in report doc generated from scheduled export (#225669)\n\n## Summary\n\nNoticed during verification that the report document generated during\nscheduled exports do not include the `space_id` field. We added it for\nsingle exports in [this\nPR](#221375) but forgot to update\nthe scheduled export feature to pass through the space ID.\n\n## To Verify\n\n1. Create a scheduled export and wait for it to generate a report\n2. Look for the doc in `.kibana-reporting`. It should contain the\n`space_id` field.\n\nCo-authored-by: Elastic Machine <[email protected]>","sha":"d43d90094aa2c6902624ccccd1c199f73fbfe9de"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/225669","number":225669,"mergeCommit":{"message":"[Response Ops][Reporting] Store `space_id` in report doc generated from scheduled export (#225669)\n\n## Summary\n\nNoticed during verification that the report document generated during\nscheduled exports do not include the `space_id` field. We added it for\nsingle exports in [this\nPR](#221375) but forgot to update\nthe scheduled export feature to pass through the space ID.\n\n## To Verify\n\n1. Create a scheduled export and wait for it to generate a report\n2. Look for the doc in `.kibana-reporting`. It should contain the\n`space_id` field.\n\nCo-authored-by: Elastic Machine <[email protected]>","sha":"d43d90094aa2c6902624ccccd1c199f73fbfe9de"}}]}] BACKPORT--> Co-authored-by: Ying Mao <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
1 parent 9672791 commit 106c69d

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

x-pack/platform/plugins/private/reporting/server/lib/store/scheduled_report.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ test('ScheduledReport should return correctly formatted outputs', () => {
2222
kibanaId: 'instance-uuid',
2323
kibanaName: 'kibana',
2424
queueTimeout: 120000,
25+
spaceId: 'a-space',
2526
scheduledReport: {
2627
id: 'report-so-id-111',
2728
attributes: {
@@ -81,6 +82,7 @@ test('ScheduledReport should return correctly formatted outputs', () => {
8182
version: '8.0.0',
8283
},
8384
scheduled_report_id: 'report-so-id-111',
85+
space_id: 'a-space',
8486
status: 'processing',
8587
started_at: expect.any(String),
8688
process_expiration: expect.any(String),
@@ -103,6 +105,7 @@ test('ScheduledReport should return correctly formatted outputs', () => {
103105
status: 'processing',
104106
attempts: 1,
105107
started_at: expect.any(String),
108+
space_id: 'a-space',
106109
migration_version: '7.14.0',
107110
output: {},
108111
queue_time_ms: expect.any(Number),
@@ -140,6 +143,7 @@ test('ScheduledReport should throw an error if report payload is malformed', ()
140143
references: [],
141144
type: 'scheduled-report',
142145
},
146+
spaceId: 'another-space',
143147
});
144148
};
145149
expect(createInstance).toThrowErrorMatchingInlineSnapshot(
@@ -154,6 +158,7 @@ test('ScheduledReport should throw an error if scheduled_report saved object is
154158
kibanaId: 'instance-uuid',
155159
kibanaName: 'kibana',
156160
queueTimeout: 120000,
161+
spaceId: 'another-space',
157162
// @ts-expect-error - missing id
158163
scheduledReport: {
159164
attributes: {

x-pack/platform/plugins/private/reporting/server/lib/store/scheduled_report.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ interface ConstructorOpts {
1818
kibanaId: string;
1919
kibanaName: string;
2020
queueTimeout: number;
21+
spaceId: string;
2122
scheduledReport: SavedObject<ScheduledReportType>;
2223
}
2324

@@ -26,7 +27,7 @@ export class ScheduledReport extends Report {
2627
* Create a report from a scheduled_report saved object
2728
*/
2829
constructor(opts: ConstructorOpts) {
29-
const { kibanaId, kibanaName, runAt, scheduledReport, queueTimeout } = opts;
30+
const { kibanaId, kibanaName, runAt, scheduledReport, spaceId, queueTimeout } = opts;
3031
const now = moment.utc();
3132
const startTime = now.toISOString();
3233
const expirationTime = now.add(queueTimeout).toISOString();
@@ -62,6 +63,7 @@ export class ScheduledReport extends Report {
6263
started_at: startTime,
6364
timeout: queueTimeout,
6465
scheduled_report_id: scheduledReport.id,
66+
space_id: spaceId,
6567
},
6668
{ queue_time_ms: [now.diff(moment.utc(runAt), 'milliseconds')] }
6769
);

x-pack/platform/plugins/private/reporting/server/lib/tasks/run_scheduled_report.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ describe('Run Scheduled Report Task', () => {
337337
kibana_name: 'kibana',
338338
kibana_id: 'instance-uuid',
339339
started_at: expect.any(String),
340+
space_id: 'default',
340341
timeout: 120000,
341342
max_attempts: 1,
342343
process_expiration: expect.any(String),

x-pack/platform/plugins/private/reporting/server/lib/tasks/run_scheduled_report.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export class RunScheduledReportTask extends RunReportTask<ScheduledReportTaskPar
6666
kibanaName: this.kibanaName!,
6767
queueTimeout: this.queueTimeout,
6868
scheduledReport,
69+
spaceId: reportSpaceId,
6970
})
7071
);
7172

0 commit comments

Comments
 (0)