Documentation

InfluxDBOutNode

The influxDBOut node writes data to InfluxDB as it is received.

Example:

stream
  |from()
    .measurement('requests')
  |eval(lambda: "errors" / "total")
    .as('error_percent')
  // Write the transformed data to InfluxDB
  |influxDBOut()
    .database('mydb')
    .retentionPolicy('myrp')
    .measurement('errors')
    .tag('kapacitor', 'true')
    .tag('version', '0.2')

Available Statistics:

  • points_written: number of points written to InfluxDB
  • write_errors: number of errors attempting to write to InfluxDB

Constructor

Chaining Method Description
influxDBOut ( ) Create an influxdb output node that will store the incoming data into InfluxDB.

Property Methods

Setters Description
buffer ( value int64) Number of points to buffer when writing to InfluxDB. Default: 1000
cluster ( value string) The name of the InfluxDB instance to connect to. If empty the configured default will be used.
create ( ) Create indicates that both the database and retention policy will be created, when the task is started. If the retention policy name is empty then no retention policy will be specified and the default retention policy name will be created.
database ( value string) The name of the database.
flushInterval ( value time.Duration) Write points to InfluxDB after interval even if buffer is not full. Default: 10s
measurement ( value string) The name of the measurement.
precision ( value string) The precision to use when writing the data.
quiet ( ) Suppress all error logging events from this node.
retentionPolicy ( value string) The name of the retention policy.
tag ( key stringvalue string) Add a static tag to all data points. Tag can be called more then once.
writeConsistency ( value string) The write consistency to use when writing the data.

Chaining Methods

Deadman, Stats


Properties

Property methods modify state on the calling node. They do not add another node to the pipeline, and always return a reference to the calling node. Property methods are marked using the . operator.

Buffer

Number of points to buffer when writing to InfluxDB. Default: 1000

influxDBOut.buffer(value int64)

Cluster

The name of the InfluxDB instance to connect to. If empty the configured default will be used.

influxDBOut.cluster(value string)

Create

Create indicates that both the database and retention policy will be created, when the task is started. If the retention policy name is empty then no retention policy will be specified and the default retention policy name will be created.

If the database already exists nothing happens.

influxDBOut.create()

Database

The name of the database.

influxDBOut.database(value string)

FlushInterval

Write points to InfluxDB after interval even if buffer is not full. Default: 10s

influxDBOut.flushInterval(value time.Duration)

Measurement

The name of the measurement.

influxDBOut.measurement(value string)

Precision

The precision to use when writing the data.

influxDBOut.precision(value string)

Quiet

Suppress all error logging events from this node.

influxDBOut.quiet()

RetentionPolicy

The name of the retention policy.

influxDBOut.retentionPolicy(value string)

Tag

Add a static tag to all data points. Tag can be called more then once.

influxDBOut.tag(key string, value string)

WriteConsistency

The write consistency to use when writing the data.

influxDBOut.writeConsistency(value string)

Chaining Methods

Chaining methods create a new node in the pipeline as a child of the calling node. They do not modify the calling node. Chaining methods are marked using the | operator.

Deadman

Helper function for creating an alert on low throughput, a.k.a. deadman’s switch.

  • Threshold: trigger alert if throughput drops below threshold in points/interval.
  • Interval: how often to check the throughput.
  • Expressions: optional list of expressions to also evaluate. Useful for time of day alerting.

Example:

    var data = stream
        |from()...
    // Trigger critical alert if the throughput drops below 100 points per 10s and checked every 10s.
    data
        |deadman(100.0, 10s)
    //Do normal processing of data
    data...

The above is equivalent to this example:

    var data = stream
        |from()...
    // Trigger critical alert if the throughput drops below 100 points per 10s and checked every 10s.
    data
        |stats(10s)
            .align()
        |derivative('emitted')
            .unit(10s)
            .nonNegative()
        |alert()
            .id('node \'stream0\' in task \'{{ .TaskName }}\'')
            .message('{{ .ID }} is {{ if eq .Level "OK" }}alive{{ else }}dead{{ end }}: {{ index .Fields "emitted" | printf "%0.3f" }} points/10s.')
            .crit(lambda: "emitted" <= 100.0)
    //Do normal processing of data
    data...

The id and message alert properties can be configured globally via the ‘deadman’ configuration section.

Since the AlertNode is the last piece it can be further modified as usual. Example:

    var data = stream
        |from()...
    // Trigger critical alert if the throughput drops below 100 points per 10s and checked every 10s.
    data
        |deadman(100.0, 10s)
            .slack()
            .channel('#dead_tasks')
    //Do normal processing of data
    data...

You can specify additional lambda expressions to further constrain when the deadman’s switch is triggered. Example:

    var data = stream
        |from()...
    // Trigger critical alert if the throughput drops below 100 points per 10s and checked every 10s.
    // Only trigger the alert if the time of day is between 8am-5pm.
    data
        |deadman(100.0, 10s, lambda: hour("time") >= 8 AND hour("time") <= 17)
    //Do normal processing of data
    data...
influxDBOut|deadman(threshold float64, interval time.Duration, expr ...ast.LambdaNode)

Returns: AlertNode

Stats

Create a new stream of data that contains the internal statistics of the node. The interval represents how often to emit the statistics based on real time. This means the interval time is independent of the times of the data points the source node is receiving.

influxDBOut|stats(interval time.Duration)

Returns: StatsNode


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.

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: