influxdata / influxdata/influxdb-client-java

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

Open
#566 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
477
Forks
129
PR merge metrics
No merged PRs in 30d

Description

__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`
```bash
influx v1 auth create \
--read-bucket 28c2cbcbac4cf29f --write-bucket 28c2cbcbac4cf29f \
--username UserName
```
5. Create v1 database with name `DataBase` and retention policy `auto`
```bash
influx v1 dbrp create \
--bucket-id 28c2cbcbac4cf29f --db DataBase --rp auto
```
7. Try to write some metrics via V1 endpoint:
```java
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.
```java
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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with InfluxDBClientFactory.createV1 and follow the request path into makeWriteApi and AbstractWriteClient. Compare the generated request with the documented InfluxDB 1.x /write endpoint and verify the fix using the reproduction against InfluxDB 2.6.1, including the expected path and authorization behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.