Documentation

Task configuration options

Task options define specific information about a task. They are set in a Flux script , in the InfluxDB API, or in the InfluxDB user interface (UI). The following task options are available:

every and cron are mutually exclusive, but at least one is required.

name

The name of the task. Required.

Data type: String

In Flux:

option task = {
    name: "taskName",
    // ...
}
  • Copy
  • Fill window
In a `/api/v2/tasks` request body with `scriptID`:
{
  "scriptID": "SCRIPT_ID",
  "name": "TASK_NAME"
  ...
}
  • Copy
  • Fill window

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).

Data type: Duration

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}

The task first executes at 3:00pm, and subsequently every hour after that.

In Flux:

option task = {
    // ...
    every: 1h,
}
  • Copy
  • Fill window
In a `/api/v2/tasks` request body with `scriptID`:
{
  "scriptID": "SCRIPT_ID",
  "every": "1h"
  ...
}
  • Copy
  • Fill window

In the InfluxDB UI, use the Interval field to set this option.

cron

The cron expression that defines the schedule on which the task runs. Cron scheduling is based on system time.

Data type: String

In Flux:

option task = {
    // ...
    cron: "0 * * * *",
}
  • Copy
  • Fill window
In a `/api/v2/tasks` request body with `scriptID`:
{
  "scriptID": "SCRIPT_ID",
  "cron": "0 * * * *",
  ...
}
  • Copy
  • Fill window

offset

Delays the execution of the task but preserves the original time range. For example, if a task is to run on the hour, a 10m offset will delay it to 10 minutes after the hour, but all time ranges defined in the task are relative to the specified execution time. A common use case is offsetting execution to account for data that may arrive late.

Data type: Duration

In Flux:

option task = {
    // ...
    offset: 10m,
}
  • Copy
  • Fill window

In a /api/v2/tasks request body with scriptID:

{
  "scriptID": "SCRIPT_ID",
  "offset": "10m",
  ...
}
  • Copy
  • Fill window

Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more

InfluxDB 3 Core and Enterprise are now in Beta

InfluxDB 3 Core and Enterprise are now available for beta testing, available under MIT or Apache 2 license.

InfluxDB 3 Core is a high-speed, recent-data engine that collects and processes data in real-time, while persisting it to local disk or object storage. InfluxDB 3 Enterprise is a commercial product that builds on Core’s foundation, adding high availability, read replicas, enhanced security, and data compaction for faster queries. A free tier of InfluxDB 3 Enterprise will also be available for at-home, non-commercial use for hobbyists to get the full historical time series database set of capabilities.

For more information, check out:

InfluxDB Cloud powered by TSM