Writing data to influxdb 2.7.4 using java client library 6.6.0

Vikash_Rai
Wed, 10 Jan 2024 19:03:28 +0000
Systems

I encountered an issue while attempting to ingest records into InfluxDB 2.7.4 using the Java Client Library version 6.6.0. Despite using a POJO and its corresponding class for data writing, I am unable to successfully ingest records.

Specifically, I am trying to set a custom timestamp (e.g., “2023-12-13T07:20:23.021Z”) in the _time column, but for some reason, the current timestamp is being stored in the _time column when writing the data.

@Measurement(name = “temperature”)
public class Temperature {

@Column(tag = true)
String location;

@Column
Double value;

@Column(timestamp = true)
Instant time;
//getters and setters

}
And the code snippet for writing the data:

WriteApiBlocking writeApi = influxDBClient.getWriteApiBlocking();

Temperature temperature = new Temperature();
temperature.setLocation(“south”);
temperature.setValue(62D);
temperature.setTime(Instant.parse(“2023-12-13T07:20:23.021Z”));

writeApi.writeMeasurement(WritePrecision.NS, temperature);
influxDBClient.close();

I would appreciate any insights or assistance in resolving this timestamp issue. Thank you!

2 posts - 2 participants