0

I am trying to write data to influx with the Node-Influx Library. I want to write historical data to influx using the timestamp in the data and the timestamp value in influx.

export class DeviceInfluxDbAccessor extends BaseInfluxDbAccessor {
    public writeDeviceReading(device: Device) {
        const fields = {
            timestamp: device.timestamp
            voltage1: device.voltage1,
        };

        this.influx
            .writePoints([
                {
                    measurement: "Device",
                    fields,
                },
            ])
            .then(() => console.log(`Wrote ${device.id} status to influx.`))
            .catch(err => console.log(err));
    }
}

However the timestamp data seams to be overitten by the influx timestamp

BigL
  • 165
  • 1
  • 2
  • 15

1 Answers1

0

InfluxDB assumes that timestamps have nanosecond precision. So, while inserting multiply timestamp by 1000000.

const fields = {
      timestamp: device.timestamp*1000000
      voltage1: device.voltage1,
};
Shreeram K
  • 1,719
  • 13
  • 22