Cloud Stack Ninja

My project is currently using influxdb-java to connect to Influx 1.8.2. Currently my code looks something like this:

InfluxDB connection = InfluxDBFactory.connect(server, client);
BatchPoints batchPoints = BatchPoints.database(database).build();

long currTime = System.currentTimeMillis()*1000000;
double[] data1 = getInfluxData();
for (int i=someInt; i < data1.length; i++){
    if (i % someInt == 0){
        double[] data2 = processData(data1, i-someInt, i);
        for (int j=0; j < data2.length; j++){
            Point p = Point.measurement(someTable)
                .time(currTime+i+j, TimeUnit.NANOSECONDS)   //Line A (j < someInt)
                .tag("someTag", "someTagValue")
                .addField("someField", data2[j])

Currently, Line A needs to be present, otherwise it seems my points overwrite themselves and only 1 point will actually get written out to someTable. Thus, Line A is a hacky solution but it's the only way I can get all points written out. The inspiration for the use of batchPoints like this came from influx's own example performance tests where they don't even specify a time. So what am I doing wrong that's causing the points to overwrite if not for Line A? Might be switching influxdb-client-java instead, just for context, in case that might alleviate this issue.

Read more here:

Content Attribution

This content was originally published by Isaac at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: