Documentation

Use Kapacitor with InfluxDB Cloud

Kapacitor is a data processing framework that makes it easy to create alerts, run ETL jobs and detect anomalies. Kapacitor interacts with InfluxDB Cloud and InfluxDB OSS Cloud using the InfluxDB 1.x compatibility API, so you can continue using Kapacitor without having to migrate libraries of TICKscripts to InfluxDB tasks.

Support for stream tasks

InfluxDB Cloud and InfluxDB OSS Cloud do not have subscription APIs and do not support Kapacitor stream tasks, but you can continue to use stream tasks by writing data directly to Kapacitor. For more information, see below.

On this page

Configure Kapacitor to connect to InfluxDB

To connect Kapacitor to InfluxDB Cloud or InfluxDB OSS Cloud, update the [[influxdb]] section(s) of your Kapacitor configuration file:

Specify your InfluxDB URL

Provide your InfluxDB URL in the [[influxdb]].urls configuration option. For more information, see InfluxDB Cloud regions or InfluxDB OSS URLs.

[[influxdb]]
  # ...
  urls = ["http://localhost:8086"]

Provide InfluxDB authentication credentials

InfluxDB Cloud and InfluxDB OSS Cloud require authentication. Provide the following credentials in your [[influxdb]].username and [[influxdb]].password configuration options:

  • username: InfluxDB username
  • password: InfluxDB API token
[[influxdb]]
  # ...
  username = "influxdb-username"
  password = "influxdb-token"

Kapacitor is subject to InfluxDB token permission restrictions. To query or write to an InfluxDB bucket, the InfluxDB token must have read and/or write permissions for the target bucket. For information about token permissions, see Create a token.

Disable InfluxDB subscriptions

InfluxDB Cloud and InfluxDB OSS Cloud do not have subscriptions APIs. Set the [[influxdb]].disable-subscriptionsto true to disable InfluxDB subscriptions.

[[influxdb]]
  # ...
  disable-subscriptions = true

Use Kapacitor batch tasks

Kapacitor batch tasks use the query endpoint of the 1.x compatibility API and require no change to use with InfluxDB Cloud and InfluxDB OSS. For information about writing back to InfluxDB in Kapacitor tasks, see Write back to InfluxDB below.

Use Kapacitor stream tasks

InfluxDB Cloud and OSS Cloud do not have subscription APIs and do not support Kapacitor stream tasks directly. To use Kapacitor stream tasks, write data directly to Kapacitor using the Kapacitor write API. We recommend using the Telegraf InfluxDB output plugin to write data to both InfluxDB Cloud or OSS and Kapacitor.

Write data using the Telegraf InfluxDB output plugin

To write data to both InfluxDB and Kapacitor using the InfluxDB output plugin, complete the following steps:

  1. Install Telegraf.
  2. Create a DBRP mapping.
  3. In the Telegraf InfluxDB output plugin configuration file, specify the following options, replacing database, retention_policy, username and password to match your DBRP mapping, and set skip_database_creation to true:
# Write to Kapacitor
[[outputs.influxdb]]
  urls = ["http://localhost:9092"]
  database = "example-db"
  retention_policy = "example-rp"

# Write to InfluxDB Cloud or OSS
[[outputs.influxdb]]
  urls = ["http://localhost:8086"]
  database = "example-db"
  retention_policy = "example-rp"
  username = "influxdb-username"
  password = "influxdb-token"
  skip_database_creation = true

Write back to InfluxDB

If using the Kapacitor InfluxDBOut node to write data to InfluxDB Cloud, InfluxDB maps the specified database and retention policy to a corresponding bucket. You can also manually map database/retention policy combinations (DBRPs) to buckets. For more information, see DBRP mapping and Create DBRP mappings.

The following example TICKscript writes to the my-db/my-rp bucket in InfluxDB Cloud or InfluxDB OSS Cloud.

batch
  |query('SELECT errors / total AS error_percent from requests')
  // Write the transformed data to InfluxDB
  |influxDBOut()
    .database('my-db')
    .retentionPolicy('my-rp')
    .measurement('errors')
    .tag('kapacitor', 'true')
    .tag('version', '0.2')

Was this page helpful?

Thank you for your feedback!


Introducing InfluxDB Clustered

A highly available InfluxDB 3.0 cluster on your own infrastructure.

InfluxDB Clustered is a highly available InfluxDB 3.0 cluster built for high write and query workloads on your own infrastructure.

InfluxDB Clustered is currently in limited availability and is only available to a limited group of InfluxData customers. If interested in being part of the limited access group, please contact the InfluxData Sales team.

Learn more
Contact InfluxData Sales

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.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following:

InfluxDB Cloud powered by TSM