From 4bcabbdc099145a42b8c458e1398e035de2bba2f Mon Sep 17 00:00:00 2001 From: Jason Stirnaman Date: Wed, 17 Aug 2022 14:10:11 -0500 Subject: [PATCH] fix(tasks): options (#4345). (#4346) * fix(tasks): options (#4345). - Removes non-functioning concurrency option. - Add examples for options when using scriptID. * Remove TOC link --- .../v2.3/process-data/task-options.md | 61 +++++++++++++++---- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/content/influxdb/v2.3/process-data/task-options.md b/content/influxdb/v2.3/process-data/task-options.md index 8737c5d3f..15b8a307a 100644 --- a/content/influxdb/v2.3/process-data/task-options.md +++ b/content/influxdb/v2.3/process-data/task-options.md @@ -13,24 +13,26 @@ influxdb/v2.3/tags: [tasks, flux] --- Task options define specific information about a task. -They are set in a Flux script or in the InfluxDB user interface (UI). +They are set in a Flux script {{% cloud-only %}}, in the InfluxDB API, {{% /cloud-only %}} or in the InfluxDB user interface (UI). The following task options are available: - [name](#name) - [every](#every) - [cron](#cron) - [offset](#offset) -- [concurrency](#concurrency) {{% note %}} `every` and `cron` are mutually exclusive, but at least one is required. {{% /note %}} ## name + The name of the task. _**Required**_. _**Data type:** String_ +In Flux: + ```js option task = { name: "taskName", @@ -38,12 +40,26 @@ option task = { } ``` +In a `/api/v2/tasks` request body with `scriptID`: + +```json +{ + "scriptID": "SCRIPT_ID", + "name": "TASK_NAME" + ... +} +``` + +Replace `SCRIPT_ID` with the ID of your InfluxDB invokable script. + ## every The interval at which the task runs. This option also determines when the task first starts to run, depending on the specified time (in [duration literal](/{{< latest "flux" >}}/spec/lexical-elements/#duration-literals)). _**Data type:** Duration_ +In Flux: + ```js option task = { // ... @@ -51,6 +67,16 @@ option task = { } ``` +In a `/api/v2/tasks` request body with `scriptID`: + +```json +{ + "scriptID": "SCRIPT_ID", + "every": "1h" + ... +} +``` + For example, if you save or schedule a task at 2:30 and run the task every hour (`1h`): `option task = {name: "aggregation", every: 1h}` @@ -62,12 +88,15 @@ In the InfluxDB UI, the **Interval** field sets this option. {{% /note %}} ## cron + The [cron expression](https://en.wikipedia.org/wiki/Cron#Overview) that defines the schedule on which the task runs. Cron scheduling is based on system time. _**Data type:** String_ +In Flux: + ```js option task = { // ... @@ -75,6 +104,16 @@ option task = { } ``` +In a `/api/v2/tasks` request body with `scriptID`: + +```json +{ + "scriptID": "SCRIPT_ID", + "cron": "0 * * * *", + ... +} +``` + ## offset Delays the execution of the task but preserves the original time range. @@ -85,6 +124,8 @@ A common use case is offsetting execution to account for data that may arrive la _**Data type:** Duration_ +In Flux: + ```js option task = { // ... @@ -92,16 +133,12 @@ option task = { } ``` -## concurrency -The number task of executions that can run concurrently. -If the concurrency limit is reached, all subsequent executions are queued until -other running task executions complete. +In a `/api/v2/tasks` request body with `scriptID`: -_**Data type:** Integer_ - -```js -option task = { - // ... - concurrency: 2, +```json +{ + "scriptID": "SCRIPT_ID", + "offset": "10m", + ... } ```