Documentation

Options

An option represents a storage location for any value of a specified type. Options are mutable. An option can hold different values during its lifetime.

Below is a list of built-in options currently implemented in the Flux language:

Options are not closed, meaning new options may be defined and consumed within packages and scripts. Changing the value of an option for a package changes the value for all references to that option from any other package.

now

The now option is a function that returns a time value used as a proxy for the current system time.

// Query should execute as if the below time is the current system time
option now = () => 2006-01-02T15:04:05-07:00

task

The task option schedules the execution of a Flux query.

option task = {
    name: "foo",        // Name is required.
    every: 1h,          // Task should be run at this interval.
    offset: 10m,        // Delay scheduling this task by this duration.
    cron: "0 2 * * *",  // Cron is a more sophisticated way to schedule. 'every' and 'cron' are mutually exclusive.
}

location

The location option sets the default time zone of all times in the script. The location maps the UTC offset in use at that location for a given time. The default value is timezone.utc.

import "timezone"

// Set timezone to be 5 hours west of UTC
option location = timezone.fixed(offset: -5h)

// Set location to be America/Denver
option location = timezone.location(name: "America/Denver")

The location option only affects boundaries used for windowing, specifically around time shifts like daylight savings. It does not change timestamps in the _time column, which are always UTC.


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 v3 enhancements and InfluxDB Clustered is now generally available

New capabilities, including faster query performance and management tooling advance the InfluxDB v3 product line. InfluxDB Clustered is now generally available.

InfluxDB v3 performance and features

The InfluxDB v3 product line has seen significant enhancements in query performance and has made new management tooling available. These enhancements include an operational dashboard to monitor the health of your InfluxDB cluster, single sign-on (SSO) support in InfluxDB Cloud Dedicated, and new management APIs for tokens and databases.

Learn about the new v3 enhancements


InfluxDB Clustered general availability

InfluxDB Clustered is now generally available and gives you the power of InfluxDB v3 in your self-managed stack.

Talk to us about InfluxDB Clustered