influxdata / influxdata/influxdb-client-java

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

Offen
#566 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Java
Sterne
477
Forks
129
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

__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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit InfluxDBClientFactory.createV1 und verfolgen Sie den Anfragepfad bis zu makeWriteApi und AbstractWriteClient. Vergleichen Sie die generierte Anfrage mit dem dokumentierten InfluxDB 1.x /write-Endpunkt und überprüfen Sie den Fix anhand der Reproduktion gegen InfluxDB 2.6.1, einschließlich des erwarteten Pfads und des Autorisierungsverhaltens.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
backend, databases
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.