Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
a74e49d
Support rrule for task scheduling
ersin-erdal Apr 9, 2025
6163f7e
remove redundant return
ersin-erdal Apr 9, 2025
20ecece
add functional tests
ersin-erdal Apr 11, 2025
c29a08e
[CI] Auto-commit changed files from 'node scripts/styled_components_m…
kibanamachine Apr 11, 2025
de20db1
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Apr 11, 2025
65f0960
fix linting
ersin-erdal Apr 11, 2025
2dde5f6
Merge branch '216308-support-rrule-for-task-scheduling' of github.com…
ersin-erdal Apr 11, 2025
717cadb
fix linter
ersin-erdal Apr 11, 2025
72b108e
[CI] Auto-commit changed files from 'node scripts/check_mappings_upda…
kibanamachine Apr 11, 2025
38e69ef
Merge branch 'main' into 216308-support-rrule-for-task-scheduling
ersin-erdal Apr 11, 2025
c9e71ba
[CI] Auto-commit changed files from 'node scripts/jest_integration -u…
kibanamachine Apr 11, 2025
5f6fad9
Merge branch 'main' into 216308-support-rrule-for-task-scheduling
ersin-erdal Apr 11, 2025
d05d9c8
Allowing shared concurrency task types
ymao1 Apr 14, 2025
4a04b90
Merge branch 'main' into 216308-support-rrule-for-task-scheduling
ersin-erdal Apr 14, 2025
249f14c
set second to [0]
ersin-erdal Apr 15, 2025
4c60d8e
Merge branch '216308-support-rrule-for-task-scheduling' of github.com…
ersin-erdal Apr 15, 2025
4a14142
testing schedule is more resilient
ersin-erdal Apr 15, 2025
4ec1bca
remove "only"
ersin-erdal Apr 15, 2025
1275f1e
Merge branch 'main' into 216308-support-rrule-for-task-scheduling
ersin-erdal Apr 16, 2025
8aff2c9
Merge branch 'main' into 216308-support-rrule-for-task-scheduling
ersin-erdal Apr 16, 2025
04b70a2
Merge branch 'main' into shared-concurrency-tasks
elasticmachine Apr 23, 2025
c9547ae
Merge branch 'main' into shared-concurrency-tasks
elasticmachine Apr 25, 2025
850ec64
throw when interval is not provided for the next run calculation
ersin-erdal Apr 28, 2025
10c40e5
Merge branch '216308-support-rrule-for-task-scheduling' of github.com…
ersin-erdal Apr 28, 2025
af75dfb
Merge branch 'main' into 216308-support-rrule-for-task-scheduling
ersin-erdal Apr 28, 2025
95cf333
[CI] Auto-commit changed files from 'node scripts/jest_integration -u…
kibanamachine Apr 28, 2025
d5227aa
update read me
ersin-erdal Apr 28, 2025
2a1482e
Merge branch '216308-support-rrule-for-task-scheduling' of github.com…
ersin-erdal Apr 28, 2025
372d4c7
Merge branch 'main' into shared-concurrency-tasks
elasticmachine Apr 28, 2025
62fe072
update read me
ersin-erdal Apr 28, 2025
0f0685e
export Frequency and Weekday from TM
ersin-erdal Apr 28, 2025
cc65fd5
Merge branch 'pr/217728' into report-dependencies
ymao1 Apr 28, 2025
11053d1
Merge branch 'shared-concurrency-tasks' into report-dependencies
ymao1 Apr 28, 2025
23d837d
Schedule report api
ymao1 Apr 28, 2025
bbabb1f
Schedule report api
ymao1 Apr 28, 2025
f5bb665
Cleanup
ymao1 Apr 28, 2025
5375fd2
Stubbing out task
ymao1 Apr 28, 2025
f039e51
add rrule examples
ersin-erdal Apr 29, 2025
e75e796
fix rrule example
ersin-erdal Apr 29, 2025
c7e0fdc
Schedule report task
ymao1 Apr 29, 2025
424d733
PR feedback
ymao1 Apr 29, 2025
0514306
Merge branch 'main' of github.com:elastic/kibana into shared-concurre…
ymao1 Apr 29, 2025
fd55806
Adding unit tests
ymao1 Apr 30, 2025
d42d1bd
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Apr 30, 2025
214fcd5
Fixing types
ymao1 Apr 30, 2025
5019e54
Merge branch 'scheduled-reports-task' of github.com:ymao1/kibana into…
ymao1 Apr 30, 2025
5ee4309
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Apr 30, 2025
2d6dfab
Fixing types
ymao1 Apr 30, 2025
b2d9bbd
Merge branch 'pr/217728' into report-dependencies
ymao1 Apr 30, 2025
8caeb79
Merge branch 'shared-concurrency-tasks' into report-dependencies
ymao1 Apr 30, 2025
7a0d9c5
Merge branch 'scheduled-reports' of github.com:elastic/kibana into re…
ymao1 Apr 30, 2025
64cfb78
Merge branch 'report-dependencies' into scheduled-reports-api
ymao1 Apr 30, 2025
b98f26c
Fixing types
ymao1 Apr 30, 2025
3fd59a1
Cleanup
ymao1 Apr 30, 2025
0370162
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Apr 30, 2025
ed0a7c0
Merge
ymao1 Apr 30, 2025
e47833c
Updating tests
ymao1 Apr 30, 2025
0277de9
Fixing tests
ymao1 Apr 30, 2025
b0ce938
Merge branch 'scheduled-reports-api' of github.com:ymao1/kibana into …
ymao1 Apr 30, 2025
2e48fe2
Merge branch 'scheduled-reports-api' into scheduled-reports-task
ymao1 May 1, 2025
530ac2c
Fixing tests
ymao1 May 1, 2025
cec4e50
Cleanup
ymao1 May 1, 2025
a0cff7a
Cleanup
ymao1 May 1, 2025
e770dce
Title includes runAt time
ymao1 May 2, 2025
626cf01
Merge branch 'main' into 216308-support-rrule-for-task-scheduling
ersin-erdal May 2, 2025
fbb3f85
remove mappings
ersin-erdal May 2, 2025
f361058
remove mappings
ersin-erdal May 2, 2025
7099229
[CI] Auto-commit changed files from 'node scripts/check_mappings_upda…
kibanamachine May 2, 2025
a0e3fc9
Merge
ymao1 May 2, 2025
baa41cb
Merge branch 'report-dependencies' of github.com:ymao1/kibana into re…
ymao1 May 2, 2025
2947bcc
Merge branch 'pr/217728' into report-dependencies
ymao1 May 2, 2025
3afe5b2
Fix
ymao1 May 2, 2025
dc96d64
Merge and add createdBy mapping
ymao1 May 2, 2025
c1884f3
Merge branch 'scheduled-reports-api' into scheduled-reports-task
ymao1 May 2, 2025
5398116
remove schema from v4
ersin-erdal May 2, 2025
5a800d5
Merge branch '216308-support-rrule-for-task-scheduling' of github.com…
ersin-erdal May 2, 2025
9cd5011
types types types
ymao1 May 2, 2025
8faaf40
Merge branch 'main' into 216308-support-rrule-for-task-scheduling
ersin-erdal May 3, 2025
aaf4309
Merge branch 'main' into shared-concurrency-tasks
elasticmachine May 5, 2025
5c55c02
Merge branch 'main' into 216308-support-rrule-for-task-scheduling
ersin-erdal May 5, 2025
fc2b386
Merge branch 'scheduled-reports' of github.com:elastic/kibana into re…
ymao1 May 5, 2025
4fed516
Merge branch 'shared-concurrency-tasks' into report-dependencies
ymao1 May 5, 2025
d1104e4
Merge branch 'pr/217728' into report-dependencies
ymao1 May 5, 2025
c9911fa
Merge branch 'report-dependencies' into scheduled-reports-api
ymao1 May 5, 2025
85cb015
Updating types
ymao1 May 5, 2025
e811ec2
Merge
ymao1 May 5, 2025
d18fcaf
Fixing types
ymao1 May 5, 2025
0253ced
add explicit error log when the next run at cannot be calculated
ersin-erdal May 5, 2025
590e659
Merge branch '216308-support-rrule-for-task-scheduling' of github.com…
ersin-erdal May 5, 2025
3834eaf
[CI] Auto-commit changed files from 'node scripts/styled_components_m…
kibanamachine May 5, 2025
c7e26f0
add missing logger
ersin-erdal May 5, 2025
8455d3c
Merge branch '216308-support-rrule-for-task-scheduling' of github.com…
ersin-erdal May 5, 2025
1e3d3e9
Handling notification
ymao1 May 5, 2025
bbea405
fix unit test
ersin-erdal May 5, 2025
4df59d0
Merge
ymao1 May 6, 2025
17bdcd0
Merge branch 'report-dependencies' into scheduled-reports-api
ymao1 May 6, 2025
4a4e0c5
Merge branch 'scheduled-reports-api' into scheduled-reports-task
ymao1 May 6, 2025
e20f1bf
Cleanup
ymao1 May 6, 2025
402ef5c
Merge
ymao1 May 6, 2025
d5799f5
Merge
ymao1 May 6, 2025
bfef31b
Merge branch 'pr/217728' into report-dependencies
ymao1 May 6, 2025
8cc0976
Merge branch 'report-dependencies' into scheduled-reports-api
ymao1 May 6, 2025
03c8304
Merge branch 'scheduled-reports-api' into scheduled-reports-task
ymao1 May 6, 2025
2bd0d5d
Adding schedule reports API
ymao1 May 7, 2025
d0da6b4
Merge
ymao1 May 7, 2025
9a7bda6
Fixing bad merge
ymao1 May 7, 2025
6a7b62e
Merge
ymao1 May 8, 2025
99f186c
Merge
ymao1 May 8, 2025
601fbc6
Fixing types
ymao1 May 8, 2025
bc09318
Adding cc,bcc fields and validation for max recipients
ymao1 May 8, 2025
ea37895
Merge
ymao1 May 8, 2025
d87b6f1
Merge branch 'scheduled-reports' of github.com:elastic/kibana into sc…
ymao1 May 19, 2025
def242b
Merge branch 'scheduled-reports-api' into scheduled-reports-task
ymao1 May 19, 2025
4ca09af
Merge
ymao1 May 20, 2025
f3efd5a
Fixing attempts
ymao1 May 20, 2025
4750222
Merge branch 'scheduled-reports' of github.com:elastic/kibana into sc…
ymao1 May 21, 2025
d60bbff
Merge branch 'scheduled-reports' of github.com:elastic/kibana into sc…
ymao1 May 23, 2025
3955376
Merge branch 'scheduled-reports' of github.com:elastic/kibana into sc…
ymao1 May 27, 2025
5a2c076
Merge branch 'scheduled-reports' of github.com:elastic/kibana into sc…
ymao1 May 29, 2025
1f46d45
Fixing space access
ymao1 May 29, 2025
a3ed61d
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine May 29, 2025
d95012c
Fixing types
ymao1 May 29, 2025
035d994
Merge branch 'scheduled-reports-task' of github.com:ymao1/kibana into…
ymao1 May 29, 2025
ad65b91
PR feedback
ymao1 May 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/platform/packages/private/kbn-reporting/common/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ export class AuthenticationExpiredError extends ReportingError {
}
}

export class MissingAuthenticationError extends ReportingError {
static code = 'missing_authentication_header_error' as const;
public get code(): string {
return MissingAuthenticationError.code;
}
}

export class QueueTimeoutError extends ReportingError {
static code = 'queue_timeout_error' as const;
public get code(): string {
Expand Down
2 changes: 2 additions & 0 deletions src/platform/packages/private/kbn-reporting/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface BaseParams {
objectType: string;
title: string;
version: string; // to handle any state migrations
forceNow?: string;
layout?: LayoutParams; // png & pdf only
pagingStrategy?: CsvPagingStrategy; // csv only
}
Expand Down Expand Up @@ -152,6 +153,7 @@ export interface ReportSource {
created_at: string; // timestamp in UTC
'@timestamp'?: string; // creation timestamp, only used for data streams compatibility
status: JOB_STATUS;
scheduled_report_id?: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened an Elasticsearch PR to add this field to the mapping: elastic/elasticsearch#127827


/*
* `output` is only populated if the report job is completed or failed.
Expand Down
52 changes: 41 additions & 11 deletions x-pack/platform/plugins/private/reporting/server/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ import type { ReportingSetup } from '.';
import { createConfig } from './config';
import { reportingEventLoggerFactory } from './lib/event_logger/logger';
import type { IReport, ReportingStore } from './lib/store';
import { ExecuteReportTask, ReportTaskParams } from './lib/tasks';
import {
RunSingleReportTask,
ReportTaskParams,
RunScheduledReportTask,
ScheduledReportTaskParamsWithoutSpaceId,
} from './lib/tasks';
import type { ReportingPluginRouter } from './types';
import { EventTracker } from './usage';
import { SCHEDULED_REPORT_SAVED_OBJECT_TYPE } from './saved_objects';
Expand Down Expand Up @@ -100,7 +105,8 @@ export class ReportingCore {
private pluginStartDeps?: ReportingInternalStart;
private readonly pluginSetup$ = new Rx.ReplaySubject<boolean>(); // observe async background setupDeps each are done
private readonly pluginStart$ = new Rx.ReplaySubject<ReportingInternalStart>(); // observe async background startDeps
private executeTask: ExecuteReportTask;
private runSingleReportTask: RunSingleReportTask;
private runScheduledReportTask: RunScheduledReportTask;
private config: ReportingConfigType;
private executing: Set<string>;
private exportTypesRegistry = new ExportTypesRegistry();
Expand All @@ -121,7 +127,16 @@ export class ReportingCore {
this.getExportTypes().forEach((et) => {
this.exportTypesRegistry.register(et);
});
this.executeTask = new ExecuteReportTask(this, config, this.logger);
this.runSingleReportTask = new RunSingleReportTask({
reporting: this,
config,
logger: this.logger,
});
this.runScheduledReportTask = new RunScheduledReportTask({
reporting: this,
config,
logger: this.logger,
});

this.getContract = () => ({
registerExportTypes: (id) => id,
Expand All @@ -146,9 +161,10 @@ export class ReportingCore {
et.setup(setupDeps);
});

const { executeTask } = this;
const { runSingleReportTask, runScheduledReportTask } = this;
setupDeps.taskManager.registerTaskDefinitions({
[executeTask.TYPE]: executeTask.getTaskDefinition(),
[runSingleReportTask.TYPE]: runSingleReportTask.getTaskDefinition(),
[runScheduledReportTask.TYPE]: runScheduledReportTask.getTaskDefinition(),
});
}

Expand All @@ -164,9 +180,12 @@ export class ReportingCore {
});

const { taskManager } = startDeps;
const { executeTask } = this;
const { runSingleReportTask, runScheduledReportTask } = this;
// enable this instance to generate reports
await Promise.all([executeTask.init(taskManager)]);
await Promise.all([
runSingleReportTask.init(taskManager),
runScheduledReportTask.init(taskManager),
]);
}

public pluginStop() {
Expand Down Expand Up @@ -326,7 +345,14 @@ export class ReportingCore {
}

public async scheduleTask(request: KibanaRequest, report: ReportTaskParams) {
return await this.executeTask.scheduleTask(request, report);
return await this.runSingleReportTask.scheduleTask(request, report);
}

public async scheduleRecurringTask(
request: KibanaRequest,
report: ScheduledReportTaskParamsWithoutSpaceId
) {
return await this.runScheduledReportTask.scheduleTask(request, report);
}

public async getStore() {
Expand Down Expand Up @@ -385,13 +411,17 @@ export class ReportingCore {
return dataViews;
}

public async getSoClient(request: KibanaRequest) {
public async getScopedSoClient(request: KibanaRequest) {
const { savedObjects } = await this.getPluginStartDeps();
const savedObjectsClient = savedObjects.getScopedClient(request, {
return savedObjects.getScopedClient(request, {
excludedExtensions: [SECURITY_EXTENSION_ID],
includedHiddenTypes: [SCHEDULED_REPORT_SAVED_OBJECT_TYPE],
});
return savedObjectsClient;
}

public async getInternalSoClient() {
const { savedObjects } = await this.getPluginStartDeps();
return savedObjects.createInternalRepository([SCHEDULED_REPORT_SAVED_OBJECT_TYPE]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this could be confusing in the future, since it returns either a scoped or internal client. And complicates the typing (minor concern). Would it be better to have separate methods? It seems pretty obvious to me in the code, right now ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split into separate functions in ad65b91

}

public async getDataService() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

export { Report } from './report';
export { SavedReport } from './saved_report';
export { ScheduledReport } from './scheduled_report';
export { ReportingStore } from './store';
export { IlmPolicyManager } from './ilm_policy_manager';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,61 @@ describe('Class Report', () => {
expect(report._id).toBeDefined();
});

it('constructs Report instance when scheduled_task_id is defined', () => {
const report = new Report({
_index: '.reporting-test-index-12345',
jobtype: 'test-report',
created_by: 'created_by_test_string',
max_attempts: 50,
payload: {
headers: 'payload_test_field',
objectType: 'testOt',
title: 'cool report',
version: '7.14.0',
browserTimezone: 'UTC',
},
meta: { objectType: 'test' },
timeout: 30000,
scheduled_report_id: 'foobar',
});

expect(report.toReportSource()).toMatchObject({
attempts: 0,
completed_at: undefined,
created_by: 'created_by_test_string',
jobtype: 'test-report',
max_attempts: 50,
meta: { objectType: 'test' },
payload: { headers: 'payload_test_field', objectType: 'testOt' },
started_at: undefined,
status: 'pending',
timeout: 30000,
scheduled_report_id: 'foobar',
});
expect(report.toReportTaskJSON()).toMatchObject({
attempts: 0,
created_by: 'created_by_test_string',
index: '.reporting-test-index-12345',
jobtype: 'test-report',
meta: { objectType: 'test' },
payload: { headers: 'payload_test_field', objectType: 'testOt' },
});
expect(report.toApiJSON()).toMatchObject({
attempts: 0,
created_by: 'created_by_test_string',
index: '.reporting-test-index-12345',
jobtype: 'test-report',
max_attempts: 50,
payload: { objectType: 'testOt' },
meta: { objectType: 'test' },
status: 'pending',
timeout: 30000,
scheduled_report_id: 'foobar',
});

expect(report._id).toBeDefined();
});

it('updateWithEsDoc method syncs fields to sync ES metadata', () => {
const report = new Report({
_index: '.reporting-test-index-12345',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class Report implements Partial<ReportSource & ReportDocumentHead> {

public readonly status: ReportSource['status'];
public readonly attempts: ReportSource['attempts'];
public readonly scheduled_report_id: ReportSource['scheduled_report_id'];

// fields with undefined values exist in report jobs that have not been claimed
public readonly kibana_name: ReportSource['kibana_name'];
Expand Down Expand Up @@ -97,6 +98,7 @@ export class Report implements Partial<ReportSource & ReportDocumentHead> {
this.status = opts.status || JOB_STATUS.PENDING;
this.output = opts.output || null;
this.error = opts.error;
this.scheduled_report_id = opts.scheduled_report_id;

this.queue_time_ms = fields?.queue_time_ms;
this.execution_time_ms = fields?.execution_time_ms;
Expand Down Expand Up @@ -139,6 +141,7 @@ export class Report implements Partial<ReportSource & ReportDocumentHead> {
process_expiration: this.process_expiration,
output: this.output || null,
metrics: this.metrics,
scheduled_report_id: this.scheduled_report_id,
};
}

Expand Down Expand Up @@ -187,6 +190,7 @@ export class Report implements Partial<ReportSource & ReportDocumentHead> {
payload: omit(this.payload, 'headers'),
output: omit(this.output, 'content'),
metrics: this.metrics,
scheduled_report_id: this.scheduled_report_id,
};
}
}
Loading