Support rrule for task scheduling#217728
Conversation
…:ersin-erdal/kibana into 216308-support-rrule-for-task-scheduling
… src/core/server/integration_tests/ci_checks'
| if ( | ||
| get(taskInstance, 'schedule.interval', null) == null && | ||
| get(taskInstance, 'schedule.rrule', null) == null | ||
| ) { |
There was a problem hiding this comment.
Probably checking for schedule is enough.
…:ersin-erdal/kibana into 216308-support-rrule-for-task-scheduling
|
Pinging @elastic/response-ops (Team:ResponseOps) |
ymao1
left a comment
There was a problem hiding this comment.
LGTM. Left a question about having a fallback for Rrrule.after and a request to add a comment about the logic behind testing if an rrule has a fixed interval.
…:ersin-erdal/kibana into 216308-support-rrule-for-task-scheduling
…:ersin-erdal/kibana into 216308-support-rrule-for-task-scheduling
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Public APIs missing exports
History
|
|
Starting backport for target branches: 8.19 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
Resolves: elastic#216308 This PR adds rrule notation support to the task scheduling. Currently we use a simple interval string (such as `1h` or `45m`) to calculate the next `runAt` that we use to decide if the task should be picked up or not. With this PR, we will be able to use rrule as well. We set the `runAt` field in 3 places: - At task creation: when the task is created for the first time, this is always `now` if a specific runAt is not provided. - At task update. We update runAt on task update as well but only when it is provided. We don't update it when the schedule config changes. - After task run: to decide when the next run will be after a task is run. This PR modifies: - At task creation: It still uses the `runAt` when it is provided but calculates a runAt by using rrule if the config has a fixed time (like every day at 13:00) config. Becausethe task should not run immediately when there is a fixed time to run. - After task run: It calculates the next `runAt` with rrule when it is provided. This PR doesn't apply any change on `At task update` as it requires a further investigation and consideration. We will handle it with a follow-on issue. You can use the test task `sampleRecurringTask` to test the feature. Just create a task with rrule in the schedule config. Then check the runAt field in the task SO to see if it is the expected datetime. Then run the task one more time and check the new `runAt` I also used the usage reporting task in the actions plugin to test the feature. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 0878a09)
|
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
2 similar comments
|
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
|
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
# Backport This will backport the following commits from `main` to `8.19`: - [Support rrule for task scheduling (#217728)](#217728) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Ersin Erdal","email":"92688503+ersin-erdal@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-05-07T12:39:11Z","message":"Support rrule for task scheduling (#217728)\n\nResolves: https://github.com/elastic/kibana/issues/216308\n\nThis PR adds rrule notation support to the task scheduling.\n\nCurrently we use a simple interval string (such as `1h` or `45m`) to\ncalculate the next `runAt` that we use to decide if the task should be\npicked up or not. With this PR, we will be able to use rrule as well.\n\nWe set the `runAt` field in 3 places:\n- At task creation: when the task is created for the first time, this is\nalways `now` if a specific runAt is not provided.\n- At task update. We update runAt on task update as well but only when\nit is provided. We don't update it when the schedule config changes.\n- After task run: to decide when the next run will be after a task is\nrun.\n\nThis PR modifies:\n- At task creation: It still uses the `runAt` when it is provided but\ncalculates a runAt by using rrule if the config has a fixed time (like\nevery day at 13:00) config. Becausethe task should not run immediately\nwhen there is a fixed time to run.\n- After task run: It calculates the next `runAt` with rrule when it is\nprovided.\n\nThis PR doesn't apply any change on `At task update` as it requires a\nfurther investigation and consideration. We will handle it with a\nfollow-on issue.\n\n## To verify:\nYou can use the test task `sampleRecurringTask` to test the feature.\nJust create a task with rrule in the schedule config.\nThen check the runAt field in the task SO to see if it is the expected\ndatetime.\nThen run the task one more time and check the new `runAt`\n\nI also used the usage reporting task in the actions plugin to test the\nfeature.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"0878a095a556b09bd05695469539c25be2c3423d","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:ResponseOps","backport missing","release_note:feature","backport:version","v9.1.0","v8.19.0"],"title":"Support rrule for task scheduling","number":217728,"url":"https://github.com/elastic/kibana/pull/217728","mergeCommit":{"message":"Support rrule for task scheduling (#217728)\n\nResolves: https://github.com/elastic/kibana/issues/216308\n\nThis PR adds rrule notation support to the task scheduling.\n\nCurrently we use a simple interval string (such as `1h` or `45m`) to\ncalculate the next `runAt` that we use to decide if the task should be\npicked up or not. With this PR, we will be able to use rrule as well.\n\nWe set the `runAt` field in 3 places:\n- At task creation: when the task is created for the first time, this is\nalways `now` if a specific runAt is not provided.\n- At task update. We update runAt on task update as well but only when\nit is provided. We don't update it when the schedule config changes.\n- After task run: to decide when the next run will be after a task is\nrun.\n\nThis PR modifies:\n- At task creation: It still uses the `runAt` when it is provided but\ncalculates a runAt by using rrule if the config has a fixed time (like\nevery day at 13:00) config. Becausethe task should not run immediately\nwhen there is a fixed time to run.\n- After task run: It calculates the next `runAt` with rrule when it is\nprovided.\n\nThis PR doesn't apply any change on `At task update` as it requires a\nfurther investigation and consideration. We will handle it with a\nfollow-on issue.\n\n## To verify:\nYou can use the test task `sampleRecurringTask` to test the feature.\nJust create a task with rrule in the schedule config.\nThen check the runAt field in the task SO to see if it is the expected\ndatetime.\nThen run the task one more time and check the new `runAt`\n\nI also used the usage reporting task in the actions plugin to test the\nfeature.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"0878a095a556b09bd05695469539c25be2c3423d"}},"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/217728","number":217728,"mergeCommit":{"message":"Support rrule for task scheduling (#217728)\n\nResolves: https://github.com/elastic/kibana/issues/216308\n\nThis PR adds rrule notation support to the task scheduling.\n\nCurrently we use a simple interval string (such as `1h` or `45m`) to\ncalculate the next `runAt` that we use to decide if the task should be\npicked up or not. With this PR, we will be able to use rrule as well.\n\nWe set the `runAt` field in 3 places:\n- At task creation: when the task is created for the first time, this is\nalways `now` if a specific runAt is not provided.\n- At task update. We update runAt on task update as well but only when\nit is provided. We don't update it when the schedule config changes.\n- After task run: to decide when the next run will be after a task is\nrun.\n\nThis PR modifies:\n- At task creation: It still uses the `runAt` when it is provided but\ncalculates a runAt by using rrule if the config has a fixed time (like\nevery day at 13:00) config. Becausethe task should not run immediately\nwhen there is a fixed time to run.\n- After task run: It calculates the next `runAt` with rrule when it is\nprovided.\n\nThis PR doesn't apply any change on `At task update` as it requires a\nfurther investigation and consideration. We will handle it with a\nfollow-on issue.\n\n## To verify:\nYou can use the test task `sampleRecurringTask` to test the feature.\nJust create a task with rrule in the schedule config.\nThen check the runAt field in the task SO to see if it is the expected\ndatetime.\nThen run the task one more time and check the new `runAt`\n\nI also used the usage reporting task in the actions plugin to test the\nfeature.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"0878a095a556b09bd05695469539c25be2c3423d"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Towards #216313 > [!Note] > This PR will be merged into a feature branch - `elastic:scheduled-reports` > Once this is merged, I will open a draft PR from the feature branch into `main` ## Summary ### Schedule API - Added internal API `/internal/reporting/schedule/{exportTypeId}` ``` POST /internal/reporting/schedule/{exportTypeId} { "jobParams": <same jobParams format as existing generate single report API>, "schedule": { "rrule": <modified Task Manager rRule schema from #217728> } "notification": { "email": { "to": <optional list of email addresses>, "cc": <optional list of email addresses>, "bcc": <optional list of email addresses> } } ``` - Scheduling a report creates a new `scheduled_report` type saved object in the `.kibana-alerting-cases` index. - Uses the same role privileges as the current generate report API, so user must have the reporting subfeature privilege for one of the Analytics feature privileges (Discover/Dashboard/Visualize) ## Verify 1. Run ES and Kibana with examples and install the sample web logs data set. 2. In the DEV console, call the schedule API using ``` POST kbn:/internal/reporting/schedule/printablePdfV2 { "schedule": { "rrule": { "freq": 3, "interval": 3, "byhour": [12], "byminute": [0] } }, "jobParams": "(browserTimezone:America/New_York,layout:(dimensions:(height:2220,width:1364),id:preserve_layout),locatorParams:!((id:DASHBOARD_APP_LOCATOR,params:(dashboardId:edf84fe0-e1a0-11e7-b6d5-4dc382ef7f5b,preserveSavedFilters:!t,timeRange:(from:now-7d/d,to:now),useHash:!f,viewMode:view))),objectType:dashboard,title:'[Logs] Web Traffic',version:'9.1.0')" } ``` 3. Verify a saved object has been created using `GET .kibana_alerting_cases/_search?q=type:scheduled_report` 4. Try different requests with different schedules and notifications. It should respect the email domain allowlist if configured and reject invalid rrule schedules and email addresses. --------- Co-authored-by: Ersin Erdal <ersin.erdal@elastic.co> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Ersin Erdal <92688503+ersin-erdal@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
…219429) Towards: elastic#216308 This PR adds the `rrule` schema to the task SO with an intermediate release for the following PR: elastic#217728 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Resolves: elastic#216308 This PR adds rrule notation support to the task scheduling. Currently we use a simple interval string (such as `1h` or `45m`) to calculate the next `runAt` that we use to decide if the task should be picked up or not. With this PR, we will be able to use rrule as well. We set the `runAt` field in 3 places: - At task creation: when the task is created for the first time, this is always `now` if a specific runAt is not provided. - At task update. We update runAt on task update as well but only when it is provided. We don't update it when the schedule config changes. - After task run: to decide when the next run will be after a task is run. This PR modifies: - At task creation: It still uses the `runAt` when it is provided but calculates a runAt by using rrule if the config has a fixed time (like every day at 13:00) config. Becausethe task should not run immediately when there is a fixed time to run. - After task run: It calculates the next `runAt` with rrule when it is provided. This PR doesn't apply any change on `At task update` as it requires a further investigation and consideration. We will handle it with a follow-on issue. ## To verify: You can use the test task `sampleRecurringTask` to test the feature. Just create a task with rrule in the schedule config. Then check the runAt field in the task SO to see if it is the expected datetime. Then run the task one more time and check the new `runAt` I also used the usage reporting task in the actions plugin to test the feature. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
…219429) Towards: elastic#216308 This PR adds the `rrule` schema to the task SO with an intermediate release for the following PR: elastic#217728 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Resolves: elastic#216308 This PR adds rrule notation support to the task scheduling. Currently we use a simple interval string (such as `1h` or `45m`) to calculate the next `runAt` that we use to decide if the task should be picked up or not. With this PR, we will be able to use rrule as well. We set the `runAt` field in 3 places: - At task creation: when the task is created for the first time, this is always `now` if a specific runAt is not provided. - At task update. We update runAt on task update as well but only when it is provided. We don't update it when the schedule config changes. - After task run: to decide when the next run will be after a task is run. This PR modifies: - At task creation: It still uses the `runAt` when it is provided but calculates a runAt by using rrule if the config has a fixed time (like every day at 13:00) config. Becausethe task should not run immediately when there is a fixed time to run. - After task run: It calculates the next `runAt` with rrule when it is provided. This PR doesn't apply any change on `At task update` as it requires a further investigation and consideration. We will handle it with a follow-on issue. ## To verify: You can use the test task `sampleRecurringTask` to test the feature. Just create a task with rrule in the schedule config. Then check the runAt field in the task SO to see if it is the expected datetime. Then run the task one more time and check the new `runAt` I also used the usage reporting task in the actions plugin to test the feature. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Resolves: #216308
This PR adds rrule notation support to the task scheduling.
Currently we use a simple interval string (such as
1hor45m) to calculate the nextrunAtthat we use to decide if the task should be picked up or not. With this PR, we will be able to use rrule as well.We set the
runAtfield in 3 places:nowif a specific runAt is not provided.This PR modifies:
runAtwhen it is provided but calculates a runAt by using rrule if the config has a fixed time (like every day at 13:00) config. Becausethe task should not run immediately when there is a fixed time to run.runAtwith rrule when it is provided.This PR doesn't apply any change on
At task updateas it requires a further investigation and consideration. We will handle it with a follow-on issue.To verify:
You can use the test task
sampleRecurringTaskto test the feature.Just create a task with rrule in the schedule config.
Then check the runAt field in the task SO to see if it is the expected datetime.
Then run the task one more time and check the new
runAtI also used the usage reporting task in the actions plugin to test the feature.