Skip to content

Commit 10c0a56

Browse files
ymao1kibanamachine
andauthored
[8.19] [Response Ops][Reporting] Scheduled Reports (#221028) (#224692)
# Backport This will backport the following commits from `main` to `8.19`: - [[Response Ops][Reporting] Scheduled Reports (#221028)](#221028) <!--- Backport version: 10.0.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Ying Mao","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-06-19T13:20:18Z","message":"[Response Ops][Reporting] Scheduled Reports (#221028)\n\nResolves https://github.com/elastic/kibana/issues/216313\n\n## Summary\n\nThis is a feature branch that contains the following commits. Each\nindividual linked PR contains a summary and verification instructions.\n\n* Schedule API - https://github.com/elastic/kibana/pull/219771\n* Scheduled report task runner -\nhttps://github.com//pull/219770\n* List and disable API - https://github.com/elastic/kibana/pull/220922\n* Audit logging - https://github.com/elastic/kibana/pull/221846\n* Send scheduled report emails -\nhttps://github.com//pull/220539\n* Commit to check license -\nhttps://github.com//pull/221028/commits/f5f9d9daedcd18447b6a02335a53631a44413788\n* Update to list API response format -\nhttps://github.com//pull/224262\n\n---------\n\nCo-authored-by: Ersin Erdal <[email protected]>\nCo-authored-by: kibanamachine <[email protected]>\nCo-authored-by: Ersin Erdal <[email protected]>\nCo-authored-by: Elastic Machine <[email protected]>\nCo-authored-by: Alexi Doak <[email protected]>","sha":"a409627765dfaf3d588c35a0d510b8d1857cd266","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:ResponseOps","release_note:feature","ci:cloud-deploy","ci:cloud-persist-deployment","Feature:Reporting:Framework","backport:version","v9.1.0","v8.19.0"],"title":"[Response Ops][Reporting] Scheduled Reports","number":221028,"url":"https://github.com/elastic/kibana/pull/221028","mergeCommit":{"message":"[Response Ops][Reporting] Scheduled Reports (#221028)\n\nResolves https://github.com/elastic/kibana/issues/216313\n\n## Summary\n\nThis is a feature branch that contains the following commits. Each\nindividual linked PR contains a summary and verification instructions.\n\n* Schedule API - https://github.com/elastic/kibana/pull/219771\n* Scheduled report task runner -\nhttps://github.com//pull/219770\n* List and disable API - https://github.com/elastic/kibana/pull/220922\n* Audit logging - https://github.com/elastic/kibana/pull/221846\n* Send scheduled report emails -\nhttps://github.com//pull/220539\n* Commit to check license -\nhttps://github.com//pull/221028/commits/f5f9d9daedcd18447b6a02335a53631a44413788\n* Update to list API response format -\nhttps://github.com//pull/224262\n\n---------\n\nCo-authored-by: Ersin Erdal <[email protected]>\nCo-authored-by: kibanamachine <[email protected]>\nCo-authored-by: Ersin Erdal <[email protected]>\nCo-authored-by: Elastic Machine <[email protected]>\nCo-authored-by: Alexi Doak <[email protected]>","sha":"a409627765dfaf3d588c35a0d510b8d1857cd266"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/221028","number":221028,"mergeCommit":{"message":"[Response Ops][Reporting] Scheduled Reports (#221028)\n\nResolves https://github.com/elastic/kibana/issues/216313\n\n## Summary\n\nThis is a feature branch that contains the following commits. Each\nindividual linked PR contains a summary and verification instructions.\n\n* Schedule API - https://github.com/elastic/kibana/pull/219771\n* Scheduled report task runner -\nhttps://github.com//pull/219770\n* List and disable API - https://github.com/elastic/kibana/pull/220922\n* Audit logging - https://github.com/elastic/kibana/pull/221846\n* Send scheduled report emails -\nhttps://github.com//pull/220539\n* Commit to check license -\nhttps://github.com//pull/221028/commits/f5f9d9daedcd18447b6a02335a53631a44413788\n* Update to list API response format -\nhttps://github.com//pull/224262\n\n---------\n\nCo-authored-by: Ersin Erdal <[email protected]>\nCo-authored-by: kibanamachine <[email protected]>\nCo-authored-by: Ersin Erdal <[email protected]>\nCo-authored-by: Elastic Machine <[email protected]>\nCo-authored-by: Alexi Doak <[email protected]>","sha":"a409627765dfaf3d588c35a0d510b8d1857cd266"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <[email protected]>
1 parent 080b86e commit 10c0a56

File tree

92 files changed

+10248
-673
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+10248
-673
lines changed

packages/kbn-check-mappings-update-cli/current_fields.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,9 @@
915915
"installCount",
916916
"unInstallCount"
917917
],
918+
"scheduled_report": [
919+
"createdBy"
920+
],
918921
"search": [
919922
"description",
920923
"title"

packages/kbn-check-mappings-update-cli/current_mappings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,6 +3032,14 @@
30323032
}
30333033
}
30343034
},
3035+
"scheduled_report": {
3036+
"dynamic": false,
3037+
"properties": {
3038+
"createdBy": {
3039+
"type": "keyword"
3040+
}
3041+
}
3042+
},
30353043
"search": {
30363044
"dynamic": false,
30373045
"properties": {

src/core/server/integration_tests/saved_objects/migrations/group3/type_registrations.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ const previouslyRegisteredTypes = [
122122
'query',
123123
'rules-settings',
124124
'sample-data-telemetry',
125+
'scheduled_report',
125126
'search',
126127
'search-session',
127128
'search-telemetry',

src/platform/packages/private/kbn-reporting/common/errors.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ export class AuthenticationExpiredError extends ReportingError {
7272
}
7373
}
7474

75+
export class MissingAuthenticationError extends ReportingError {
76+
static code = 'missing_authentication_header_error' as const;
77+
public get code(): string {
78+
return MissingAuthenticationError.code;
79+
}
80+
}
81+
7582
export class QueueTimeoutError extends ReportingError {
7683
static code = 'queue_timeout_error' as const;
7784
public get code(): string {

src/platform/packages/private/kbn-reporting/common/routes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ export const INTERNAL_ROUTES = {
2525
DOWNLOAD_PREFIX: prefixInternalPath + '/jobs/download', // docId is added to the final path
2626
},
2727
DOWNLOAD_CSV: prefixInternalPath + '/generate/immediate/csv_searchsource', // DEPRECATED
28+
SCHEDULED: {
29+
LIST: prefixInternalPath + '/scheduled/list',
30+
BULK_DISABLE: prefixInternalPath + '/scheduled/bulk_disable',
31+
},
2832
HEALTH: prefixInternalPath + '/_health',
2933
GENERATE_PREFIX: prefixInternalPath + '/generate', // exportTypeId is added to the final path
34+
SCHEDULE_PREFIX: prefixInternalPath + '/schedule', // exportTypeId is added to the final path
3035
};
3136

3237
const prefixPublicPath = '/api/reporting';

src/platform/packages/private/kbn-reporting/common/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export interface BaseParams {
6666
objectType: string;
6767
title: string;
6868
version: string; // to handle any state migrations
69+
forceNow?: string;
6970
layout?: LayoutParams; // png & pdf only
7071
pagingStrategy?: CsvPagingStrategy; // csv only
7172
}
@@ -152,6 +153,7 @@ export interface ReportSource {
152153
created_at: string; // timestamp in UTC
153154
'@timestamp'?: string; // creation timestamp, only used for data streams compatibility
154155
status: JOB_STATUS;
156+
scheduled_report_id?: string;
155157

156158
/*
157159
* `output` is only populated if the report job is completed or failed.

src/platform/packages/private/kbn-reporting/server/check_license.test.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ describe('check_license', () => {
4949
it('should set management.jobTypes to undefined', () => {
5050
expect(checkLicense(exportTypesRegistry, undefined).management.jobTypes).toEqual(undefined);
5151
});
52+
53+
it('should set scheduledReports.showLinks to true', () => {
54+
expect(checkLicense(exportTypesRegistry, undefined).scheduledReports.showLinks).toEqual(true);
55+
});
56+
57+
it('should set scheduledReports.enableLinks to false', () => {
58+
expect(checkLicense(exportTypesRegistry, undefined).scheduledReports.enableLinks).toEqual(
59+
false
60+
);
61+
});
5262
});
5363

5464
describe('license information is not available', () => {
@@ -82,6 +92,16 @@ describe('check_license', () => {
8292
it('should set management.jobTypes to undefined', () => {
8393
expect(checkLicense(exportTypesRegistry, license).management.jobTypes).toEqual(undefined);
8494
});
95+
96+
it('should set scheduledReports.showLinks to true', () => {
97+
expect(checkLicense(exportTypesRegistry, license).scheduledReports.showLinks).toEqual(true);
98+
});
99+
100+
it('should set scheduledReports.enableLinks to false', () => {
101+
expect(checkLicense(exportTypesRegistry, license).scheduledReports.enableLinks).toEqual(
102+
false
103+
);
104+
});
85105
});
86106

87107
describe('license information is available', () => {
@@ -121,6 +141,18 @@ describe('check_license', () => {
121141
'printable_pdf'
122142
);
123143
});
144+
145+
it('should set scheduledReports.showLinks to true', () => {
146+
expect(checkLicense(exportTypesRegistry, license).scheduledReports.showLinks).toEqual(
147+
true
148+
);
149+
});
150+
151+
it('should set scheduledReports.enableLinks to true', () => {
152+
expect(checkLicense(exportTypesRegistry, license).scheduledReports.enableLinks).toEqual(
153+
true
154+
);
155+
});
124156
});
125157

126158
describe('& license is expired', () => {
@@ -147,6 +179,18 @@ describe('check_license', () => {
147179
it('should set management.jobTypes to undefined', () => {
148180
expect(checkLicense(exportTypesRegistry, license).management.jobTypes).toEqual(undefined);
149181
});
182+
183+
it('should set scheduledReports.showLinks to true', () => {
184+
expect(checkLicense(exportTypesRegistry, license).scheduledReports.showLinks).toEqual(
185+
true
186+
);
187+
});
188+
189+
it('should set scheduledReports.enableLinks to false', () => {
190+
expect(checkLicense(exportTypesRegistry, license).scheduledReports.enableLinks).toEqual(
191+
false
192+
);
193+
});
150194
});
151195
});
152196

@@ -175,6 +219,12 @@ describe('check_license', () => {
175219
expect(checkLicense(exportTypesRegistry, license).management.jobTypes).toEqual([]);
176220
expect(checkLicense(exportTypesRegistry, license).management.jobTypes).toHaveLength(0);
177221
});
222+
223+
it('should set scheduledReports.showLinks to false', () => {
224+
expect(checkLicense(exportTypesRegistry, license).scheduledReports.showLinks).toEqual(
225+
false
226+
);
227+
});
178228
});
179229

180230
describe('& license is expired', () => {
@@ -193,6 +243,12 @@ describe('check_license', () => {
193243
it('should set management.jobTypes to undefined', () => {
194244
expect(checkLicense(exportTypesRegistry, license).management.jobTypes).toEqual(undefined);
195245
});
246+
247+
it('should set scheduledReports.showLinks to true', () => {
248+
expect(checkLicense(exportTypesRegistry, license).scheduledReports.showLinks).toEqual(
249+
true
250+
);
251+
});
196252
});
197253
});
198254
});

src/platform/packages/private/kbn-reporting/server/check_license.ts

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
import { ILicense } from '@kbn/licensing-plugin/server';
10+
import { ILicense, LicenseType } from '@kbn/licensing-plugin/server';
11+
import {
12+
LICENSE_TYPE_CLOUD_STANDARD,
13+
LICENSE_TYPE_ENTERPRISE,
14+
LICENSE_TYPE_GOLD,
15+
LICENSE_TYPE_PLATINUM,
16+
LICENSE_TYPE_TRIAL,
17+
} from '@kbn/reporting-common';
1118
import type { ExportType } from '.';
1219
import { ExportTypesRegistry } from './export_types_registry';
1320

@@ -18,6 +25,14 @@ export interface LicenseCheckResult {
1825
jobTypes?: string[];
1926
}
2027

28+
const scheduledReportValidLicenses: LicenseType[] = [
29+
LICENSE_TYPE_TRIAL,
30+
LICENSE_TYPE_CLOUD_STANDARD,
31+
LICENSE_TYPE_GOLD,
32+
LICENSE_TYPE_PLATINUM,
33+
LICENSE_TYPE_ENTERPRISE,
34+
];
35+
2136
const messages = {
2237
getUnavailable: () => {
2338
return 'You cannot use Reporting because license information is not available at this time.';
@@ -60,6 +75,42 @@ const makeManagementFeature = (exportTypes: ExportType[]) => {
6075
};
6176
};
6277

78+
const makeScheduledReportsFeature = () => {
79+
return {
80+
id: 'scheduledReports',
81+
checkLicense: (license?: ILicense) => {
82+
if (!license || !license.type) {
83+
return {
84+
showLinks: true,
85+
enableLinks: false,
86+
message: messages.getUnavailable(),
87+
};
88+
}
89+
90+
if (!license.isActive) {
91+
return {
92+
showLinks: true,
93+
enableLinks: false,
94+
message: messages.getExpired(license),
95+
};
96+
}
97+
98+
if (!scheduledReportValidLicenses.includes(license.type)) {
99+
return {
100+
showLinks: false,
101+
enableLinks: false,
102+
message: `Your ${license.type} license does not support Scheduled reports. Please upgrade your license.`,
103+
};
104+
}
105+
106+
return {
107+
showLinks: true,
108+
enableLinks: true,
109+
};
110+
},
111+
};
112+
};
113+
63114
const makeExportTypeFeature = (exportType: ExportType) => {
64115
return {
65116
id: exportType.id,
@@ -104,6 +155,7 @@ export function checkLicense(
104155
const reportingFeatures = [
105156
...exportTypes.map(makeExportTypeFeature),
106157
makeManagementFeature(exportTypes),
158+
makeScheduledReportsFeature(),
107159
];
108160

109161
return reportingFeatures.reduce((result, feature) => {

x-pack/platform/plugins/private/canvas/server/feature.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ it(`Calls on Reporting whether to include Generate PDF as a sub-feature`, () =>
181181
"minimumLicense": "gold",
182182
"name": "Generate PDF reports",
183183
"savedObject": Object {
184-
"all": Array [],
184+
"all": Array [
185+
"scheduled_report",
186+
],
185187
"read": Array [],
186188
},
187189
"ui": Array [

x-pack/platform/plugins/private/canvas/server/feature.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export function getCanvasFeature(plugins: { reporting?: ReportingStart }): Kiban
6868
includeIn: 'all',
6969
management: { insightsAndAlerting: ['reporting'] },
7070
minimumLicense: 'gold',
71-
savedObject: { all: [], read: [] },
71+
savedObject: { all: ['scheduled_report'], read: [] },
7272
api: ['generateReport'],
7373
ui: ['generatePdf'],
7474
},

0 commit comments

Comments
 (0)