Skip to content

InfluxDB Client 6.8.0 with createV1 uses POST /api/v2/write instead of POST /write #566

Description

@polarnik

Steps to reproduce:
List the minimal actions needed to reproduce the behavior.

  1. Install InfluxDB v2
  2. Create a bucket 28c2cbcbac4cf29f
  3. Create v1 auth token with a name UserName and password: Password
influx v1 auth create \
--read-bucket 28c2cbcbac4cf29f --write-bucket 28c2cbcbac4cf29f \
--username UserName
  1. Create v1 database with name DataBase and retention policy auto
influx v1 dbrp create \
--bucket-id 28c2cbcbac4cf29f --db DataBase --rp auto
  1. Try to write some metrics via V1 endpoint:
        try (InfluxDBClient client = InfluxDBClientFactory.createV1(
               "http://127.0.0.1:8086",
               "UserName",
               "Password".toCharArray(),
                "DataBase",
               "auto"
        )) {
            try (WriteApi writeApi = client.makeWriteApi()) {
                writeApi.writePoint(point);
                writeApi.flush();
            }
        }

Expected behavior:
HTTP request via
https://docs.influxdata.com/influxdb/v2.7/reference/api/influxdb-1x/write/
HTTP request:

POST /write?db=DataBase&rp=auto HTTP/1.1
Accept: application/json
User-Agent: influxdb-client-java/6.8.0
Authorization: Basic XXXXXXXX=
Accept-Encoding: identity
Content-Type: text/plain; charset=utf-8
Content-Length: 275
Host: 127.0.0.1:8086
Connection: Keep-Alive

iteration_duration,TEST_NAME=XXXXXXXX_HTTP_INFLUXDB_V1,scenario=default avg=542.131667,count=1i,max=542.131667,med=542.131667,min=542.131667,p(30)=542.131667,p(70)=542.131667,p(80)=542.131667,p(90)=542.131667,p(95)=542.131667,p(99)=542.131667,p(99.9)=542.131667 1684842304679

Actual behavior:
HTTP request:

POST /api/v2/write?org=-&bucket=DataBase%2Fauto&precision=ms HTTP/1.1
Accept: application/json
User-Agent: influxdb-client-java/6.8.0
Authorization: Token UserName:Password
Accept-Encoding: identity
Content-Type: text/plain; charset=utf-8
Content-Length: 275
Host: 127.0.0.1:8086
Connection: Keep-Alive

iteration_duration,TEST_NAME=XXXXXXXX_HTTP_INFLUXDB_V1,scenario=default avg=542.131667,count=1i,max=542.131667,med=542.131667,min=542.131667,p(30)=542.131667,p(70)=542.131667,p(80)=542.131667,p(90)=542.131667,p(95)=542.131667,p(99)=542.131667,p(99.9)=542.131667 1684842304679

It doesn't work. Only 401 Errors.

May 23, 2023 4:47:52 PM com.influxdb.client.write.events.WriteErrorEvent logEvent
SEVERE: The error occurred during writing of data
com.influxdb.exceptions.UnauthorizedException: HTTP status code: 401; Message: unauthorized access
	at com.influxdb.internal.AbstractRestClient.responseToError(AbstractRestClient.java:115)
	at com.influxdb.internal.AbstractRestClient.toInfluxException(AbstractRestClient.java:99)
	at com.influxdb.client.internal.AbstractWriteClient.lambda$new$8(AbstractWriteClient.java:174)
	at io.reactivex.rxjava3.internal.subscribers.LambdaSubscriber.onNext(LambdaSubscriber.java:65)
	at io.reactivex.rxjava3.internal.operators.flowable.FlowableDoFinally$DoFinallySubscriber.onNext(FlowableDoFinally.java:85)
	at io.reactivex.rxjava3.internal.operators.mixed.FlowableConcatMapMaybe$ConcatMapMaybeSubscriber.drain(FlowableConcatMapMaybe.java:238)
	at io.reactivex.rxjava3.internal.operators.mixed.ConcatMapXMainSubscriber.onNext(ConcatMapXMainSubscriber.java:106)
	at com.influxdb.client.internal.flowable.BackpressureBatchesBufferStrategy$OnBackpressureBufferStrategySubscriber.drain(BackpressureBatchesBufferStrategy.java:238)
	at com.influxdb.client.internal.flowable.BackpressureBatchesBufferStrategy$OnBackpressureBufferStrategySubscriber.onNext(BackpressureBatchesBufferStrategy.java:149)
	at com.influxdb.client.internal.flowable.BackpressureBatchesBufferStrategy$OnBackpressureBufferStrategySubscriber.onNext(BackpressureBatchesBufferStrategy.java:54)
	at io.reactivex.rxjava3.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.tryEmitScalar(FlowableFlatMap.java:232)
	at io.reactivex.rxjava3.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.onNext(FlowableFlatMap.java:150)
	at io.reactivex.rxjava3.internal.operators.flowable.FlowableFilter$FilterSubscriber.tryOnNext(FlowableFilter.java:75)
	at io.reactivex.rxjava3.internal.operators.flowable.FlowableFilter$FilterSubscriber.onNext(FlowableFilter.java:53)
	at io.reactivex.rxjava3.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.tryEmit(FlowableFlatMap.java:270)
	at io.reactivex.rxjava3.internal.operators.flowable.FlowableFlatMap$InnerSubscriber.onNext(FlowableFlatMap.java:627)
	at io.reactivex.rxjava3.internal.operators.flowable.FlowableMap$MapSubscriber.onNext(FlowableMap.java:69)
	at io.reactivex.rxjava3.subscribers.SerializedSubscriber.onNext(SerializedSubscriber.java:103)
	at com.influxdb.client.internal.flowable.FlowableBufferTimedFlushable$BufferExactBoundedSubscriber.accept(FlowableBufferTimedFlushable.java:227)
	at com.influxdb.client.internal.flowable.FlowableBufferTimedFlushable$BufferExactBoundedSubscriber.accept(FlowableBufferTimedFlushable.java:85)
	at io.reactivex.rxjava3.internal.subscribers.QueueDrainSubscriber.fastPathOrderedEmitMax(QueueDrainSubscriber.java:107)
	at com.influxdb.client.internal.flowable.FlowableBufferTimedFlushable$BufferExactBoundedSubscriber.run(FlowableBufferTimedFlushable.java:281)
	at com.influxdb.client.internal.flowable.FlowableBufferTimedFlushable$BufferExactBoundedSubscriber.lambda$onSubscribe$0(FlowableBufferTimedFlushable.java:149)
	at io.reactivex.rxjava3.internal.subscribers.LambdaSubscriber.onNext(LambdaSubscriber.java:65)
	at io.reactivex.rxjava3.processors.PublishProcessor$PublishSubscription.onNext(PublishProcessor.java:361)
	at io.reactivex.rxjava3.processors.PublishProcessor.offer(PublishProcessor.java:298)
	at com.influxdb.client.internal.AbstractWriteClient.flush(AbstractWriteClient.java:190)

Specifications:

  • Client Version: 6.8.0
  • InfluxDB Version: 2.6.1
  • JDK Version: 17
  • Platform: MacOS

Workaround:
Use
https://github.com/influxdata/influxdb-java
instead of
https://github.com/influxdata/influxdb-client-java
for working with v1

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