sample.alignToNow() function

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.


Align sample data timestamps to the current time

import "influxdata/influxdb/sample"

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

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

    |> sample.alignToNow()

View input and output

Was this page helpful?

Thank you for your feedback!

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.