Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Scheduled Reports] Handling create/execute jobs with scheduling in mind #75605

Closed
tsullivan opened this issue Aug 20, 2020 · 2 comments · Fixed by #64853
Closed

[Scheduled Reports] Handling create/execute jobs with scheduling in mind #75605

tsullivan opened this issue Aug 20, 2020 · 2 comments · Fixed by #64853
Labels
discuss Feature:Reporting:Framework Reporting issues pertaining to the overall framework needs-team Issues missing a team label

Comments

@tsullivan
Copy link
Member

tsullivan commented Aug 20, 2020

ExportTypeRegistry is what provides the "create job" and "execute job" functions for each Reporting integration instance. This issue outlines how the ExportTypeRegistry will be carried over in Reporting when it uses Task Manager for queuing.

The flow of creating a reporting job has differences between "ad-hoc" reports and scheduled reports. When reports are scheduled and it is time to execute the job, Task Manager goes straight to the "Execute Job" flow.

Another difference between ad-hock and scheduled reports, is that ad-hoc reports will have a "pending" phase where they are waiting for a Kibana instance, but scheduled reports will not have that phase.

Create Job (For Ad-Hoc)

Generating a report begins with an incoming user POST request. The request body has contains a keyword field for the exportType (payload.jobType) for type of job, which is used by the ExportTypeRegistry to find the corresponding ExportTypeDefinition.

The create job request handler (referred to as controller) gives the request ExportTypeDefinition's schedule function, stores the "pending" report in historical data. The controller then saves the document in the historical index and calls Task Manager to fire an ad-hoc reporting:execute task.

To support only Ad-Hoc, there does not have to be much info in the parameters of the scheduled task. We would be able to just track the pending report's ID so it can be claimed and executed later. However, to support both ad-hoc and scheduled reports in the simplest way, the task parameters should have the full information about the report, including the encrypted headers.

Create Job (For Scheduled)

Creating a job for scheduled reports refers to creating the task parameters that are passed to Task Manager, and are part of the task instance context when the task runs. Task parameters for scheduled reports contain complete information about the report, plus encrypted headers: enough context to execute a reporting job from scratch each time the schedule is triggered.

A sample of task instance parameters (same for ad-hoc and scheduled):

  • Schedule name (report name)
  • URL of the page (PNG/PDF) or saved object ID/search source (CSV)
  • File type (PNG/PDF/CSV)
  • time range in the time picker
  • "created_by" username (assuming users will only be able to see the schedules they created)
  • encrypted request headers, or API token
  • Array of actions (slack, email, etc)
  • Recurrence (time unit string or cron expression)

Execute Job

The run function of the reporting:execute task type receives incoming tasks triggered by Task Manager, and passes the job to the corresponding ExportTypeDefinition execute job function.

As mentioned above, reports will come to the same execute flow whether they are ad-hoc or scheduled, and have the full information about the report in task parameters. There will be slight differences in the flow between ad-hoc and scheduled reports:

  • For ad-hoc reports, the task parameters will have a document ID reference pointing to a pending job that needs to be updated to "processing."
    • It would be convenient to get the report info from the pending document. To keep it simple though,the Report info should always come from task params.
  • For scheduled reports, execution must begin with calculating the next runAt time.
    • Get the next timestamp by adding the recurrence interval to the current time
    • Alternatively, an interval field can be given in the scheduling data, but we would not be able to support custom intervals
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-reporting-services (Team:Reporting Services)

@tsullivan tsullivan added the WIP Work in progress label Aug 21, 2020
@tsullivan tsullivan changed the title [Scheduled Reports] Handling create/execute jobs with Task-Manager and scheduling in mind [Scheduled Reports] Handling create/execute jobs with scheduling in mind Aug 26, 2020
@tsullivan tsullivan removed the WIP Work in progress label Aug 26, 2020
@tsullivan tsullivan added (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead Team:AppServices and removed Team:Reporting Services labels Dec 17, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServices)

@sophiec20 sophiec20 added Feature:Reporting:Framework Reporting issues pertaining to the overall framework and removed (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead (Deprecated) Team:Reporting Services labels Aug 21, 2024
@botelastic botelastic bot added the needs-team Issues missing a team label label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Feature:Reporting:Framework Reporting issues pertaining to the overall framework needs-team Issues missing a team label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants