Documentation

BatchNode

The batch node handles the creation of several child QueryNode or QueryFluxNodes. Each call to query or queryFlux creates a child batch node that can further be configured. See QueryNode and QueryFluxNode. The batch variable in batch tasks is an instance of a BatchNode.

A QueryNode or QueryFluxNode is required when using BatchNode. They defines the source and schedule for batch data and should be used before any other chaining methods.

Examples:

var errors = batch
              |query('SELECT value from errors')
              ...
var views = batch
              |query('SELECT value from views')
              ...
  • Copy
  • Fill window
var errors = batch
              |queryFlux('''
                from(bucket: "example-bucket")
                  |> range(start: -1m) 
                  |> filter(fn: (r) => r._measurement == "errors")
              ''')
              ...
var views = batch
              |queryFlux('''
                from(bucket: "example-bucket")
                  |> range(start: -1m) 
                  |> filter(fn: (r) => r._measurement == "views")
              ''')
              ...
  • Copy
  • Fill window

Available Statistics:

  • query_errors: number of errors when querying
  • batches_queried: number of batches returned from queries
  • points_queried: total number of points in batches

Constructor

Chaining MethodDescription
batchHas no constructor signature.

Property Methods

SettersDescription
quiet ( )Suppress all error logging events from this node.

Chaining Methods

Deadman, Query, FluxQuery, 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.

Quiet

Suppress all error logging events from this node.

batch.quiet()
  • Copy
  • Fill window

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 = batch
        |query()...
    // 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...
  • Copy
  • Fill window

The above is equivalent to this example:

    var data = batch
        |query()...
    // 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...
  • Copy
  • Fill window

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 = batch
        |query()...
    // 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...
  • Copy
  • Fill window

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

    var data = batch
        |query()...
    // 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...
  • Copy
  • Fill window
batch|deadman(threshold float64, interval time.Duration, expr ...ast.LambdaNode)
  • Copy
  • Fill window

Returns: AlertNode

Query

The query to execute. Must not contain a time condition in the WHERE clause or contain a GROUP BY clause. The time conditions are added dynamically according to the period, offset and schedule. The GROUP BY clause is added dynamically according to the dimensions passed to the groupBy method.

batch|query(q string)
  • Copy
  • Fill window

Returns: QueryNode

QueryFlux

The Flux query to execute.

batch|QueryFlux(queryStr string)
  • Copy
  • Fill window

Returns: QueryFluxNode

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.

batch|stats(interval time.Duration)
  • Copy
  • Fill window

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.

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: