Documentation

Create Kapacitor Flux tasks

Use the kapacitor CLI or the Kapacitor HTTP API to create Kapacitor Flux tasks.

Use the kapacitor flux task create command to create a new Kapacitor Flux task. Provide the following flags:

* Required

  • * -f, --file: Filepath to the Flux task to add
kapacitor flux task create --file /path/to/task.flux
  • Copy
  • Fill window

By default, new Flux tasks are set to active and will begin to run on their defined schedule. To disable a Flux task, update the task status.

Use the following request method and endpoint to create a new Kapacitor Flux task.

POST /kapacitor/v1/api/v2/tasks
  • Copy
  • Fill window

Provide the following with your request (* Required):

Headers

  • * Content-type: application/json

Request body

JSON object with the following schema:

  • * flux: Flux task code
  • status: Flux tasks status (active or inactive, default is active)
  • description: Flux task description
curl --request POST 'http://localhost:9092/kapacitor/v1/api/v2/tasks' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "flux": "option task = {name: \"CPU Total 1 Hour New\", every: 1h}\n\nhost = \"http://localhost:8086\"\ntoken = \"\"\n\nfrom(bucket: \"db/rp\", host:host, token:token)\n\t|> range(start: -1h)\n\t|> filter(fn: (r) =>\n\t\t(r._measurement == \"cpu\"))\n\t|> filter(fn: (r) =>\n\t\t(r._field == \"usage_system\"))\n\t|> filter(fn: (r) =>\n\t\t(r.cpu == \"cpu-total\"))\n\t|> aggregateWindow(every: 1h, fn: max)\n\t|> to(bucket: \"cpu_usage_user_total_1h\", host:host, token:token)",
    "status": "active",
    "description": "Downsample CPU data every hour"
}'
  • 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: