Skip to content

InfluxOSS writing data to bucket with retention period doesn't write data #567

Description

@aidanmorgan

I am attempting to write data to a bucket running in Influx OSS that is running inside docker (Macbook M2 Pro, Docker version: 24.0.5, Influx OSS Image Version: 2.7.1).

The WriteXXXAsyncWithIRestReponse() methods return a result that has the IsSuccessful returning True, but the status code is actually NoContent with no data actually written to the database.

Using a consistent inlux client and api configuration:

                using var influxClient = new InfluxDBClient(
                    new InfluxDBClientOptions(configuration.Url)
                    {
                        Bucket = configuration.Bucket,
                        Org = configuration.Organisation,
                        Token = configuration.Token,
                        PointSettings = { DefaultTags = configuration.DefaultTags},
                    }
                );

                var api = influxClient.GetWriteApiAsync();

The first snippet is using the WritePointsAsyncWithIRestResponse which returns NoContent, but no data is written as below:

                var response = await api.WritePointsAsyncWithIRestResponse(
                    metrics.Select(x => pointDataConverter(x, PointData.Measurement(configuration.MeasurementName)))
                        .ToList(),
                    configuration.Bucket,
                    configuration.Organisation
                );

The second snippet is using the WriteRecordsAsyncWithIRestResponse with also returns NoContent, but no data is written as below:

                var response = await api.WriteRecordsAsyncWithIRestResponse(
                    metrics.Select(x => pointDataConverter(x, PointData.Measurement(configuration.MeasurementName)))
                        .Select(x => x.ToLineProtocol()),
                    WritePrecision.Ms,
                    configuration.Bucket,
                    configuration.Organisation
                );

To try and understand what was going wrong, I thought I would put togther a quick harness that calls the API using HTTP calls directly using Flurl, which returns NoContent but the data is correctly written to the bucket:

                var request = configuration
                    .Url
                    .WithHeader("Authorization", $"Token {configuration.Token}")
                    .WithHeader("Content-Type", "text/plain; charset=utf-8")
                    .WithHeader("Accept", "application/json")
                    .AppendPathSegment("/api/v2/write")
                    .SetQueryParam("org", configuration.Organisation)
                    .SetQueryParam("bucket", configuration.Bucket)
                    .SetQueryParam("precision", "ms");

                using var response = await request.PostStringAsync(
                    string.Join("\n",
                        metrics
                            .Select(x => pointDataConverter(x, PointData.Measurement(configuration.MeasurementName)).ToLineProtocol()))
                );

Through all three different scenarios the data that is been generated is not changing (the same callback is used to convert from my internal data structure to the influx PointData structure), but only the third case actually persists data.

I would have expected that the second and third scenarios would have the same outcome given they are both writing line protocol directly, but this is not the case.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions