Documentation

sample.alignToNow() function

Flux 0.132.0+

sample.alignToNow() shifts time values in input data to align the chronological last point to now. Input data must have a _time column.

When writing static historical sample datasets to InfluxDB Cloud, use sample.alignToNow() to avoid losing sample data with timestamps outside of the retention period associated with your InfluxDB Cloud account.

Examples

Align sample data timestamps to the current time

import "influxdata/influxdb/sample"

option now = () => 2021-01-01T00:00:00Z

data = sample.data(set: "birdMigration")
  |> filter(fn: (r) =>
    r._field == "lon" and
    r.s2_cell_id == "471ed2c" and
    r.id == "91916A"
  )
  |> tail(n: 3)

data
  |> sample.alignToNow()

View input and output


Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.