Use Kapacitor with InfluxDB OSS

This page documents an earlier version of InfluxDB. InfluxDB v2.7 is the latest stable version. View this page in the v2.7 documentation.

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 2.1 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 2.1 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 2.1, 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.

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

Provide InfluxDB authentication credentials

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

  • username: InfluxDB username
  • password: InfluxDB API token
  # ...
  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 2.1 do not have subscriptions APIs. Set the [[influxdb]].disable-subscriptionsto true to disable InfluxDB subscriptions.

  # ...
  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 2.1 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 Kapcitior write API.

We recommend using Telegraf InfluxDB output plugin to write data to both InfluxDB Cloud or OSS and Kapacitor. The following example Telegraf configuration writes data to both InfluxDB and Kapacitor:

Example Telegraf configuration
# Write to Kapacitor
  urls = ["http://localhost:9092"]
  database = "example-db"
  retention_policy = "example-rp"

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

Write back to InfluxDB

If using the Kapacitor InfluxDBOut node to write data to InfluxDB Cloud or OSS 2.1, 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 Map unmapped buckets.

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

  |query('SELECT errors / total AS error_percent from requests')
  // Write the transformed data to InfluxDB
    .tag('kapacitor', 'true')
    .tag('version', '0.2')

Was this page helpful?

Thank you for your feedback!

Set your InfluxDB URL

Introducing InfluxDB 3.0

The new core of InfluxDB built with Rust and Apache Arrow. Available today in InfluxDB Cloud Dedicated.

Learn more

State of the InfluxDB Cloud Serverless documentation

The new documentation for InfluxDB Cloud Serverless is a work in progress. We are adding new information and content almost daily. Thank you for your patience!

If there is specific information you’re looking for, please submit a documentation issue.