Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding URL prefix to client #149

Closed
johnseekins opened this issue Jul 9, 2020 · 8 comments · Fixed by #152
Closed

Adding URL prefix to client #149

johnseekins opened this issue Jul 9, 2020 · 8 comments · Fixed by #152
Assignees
Milestone

Comments

@johnseekins
Copy link

johnseekins commented Jul 9, 2020

I'm currently trying to use this client to write to a VictoriaMetrics instance. They say that v2 API calls work correctly (https://victoriametrics.github.io/Cluster-VictoriaMetrics.html#url-format), but every time I try to write using this client, it appears the client is ignoring the prefix I set.

For example, if I set http://localhost:8480/insert/0:0/influx as my serverUrl, this client appears to use http://localhost:8480/api/v2/write instead of http://localhost:8480/insert/0:0/influx/api/v2/write as I would expect.

Am I doing something wrong in the client? My actual instantiation:

    client := influxdb2.NewClientWithOptions(
        fmt.Sprintf("http://%v:%v/insert/0:0/influx", hostname, port),
        "",
        influxdb2.DefaultOptions().SetBatchSize(BatchSize),
    )
    writeApi := client.WriteApi("", "telegraf")

The error I receive:

Jul 09 14:34:06 <> vminsert-prod[6281]: 2020-07-09T14:34:06.206Z        warn        VictoriaMetrics/lib/httpserver/httpserver.go:204        unsupported path requested: "/api/v2/write"

A similar error I received using the v1 client:

Jul 08 22:42:20 <> vminsert-prod[6281]: 2020-07-08T22:42:20.815Z        warn        VictoriaMetrics/lib/httpserver/httpserver.go:204        unsupported path requested: "/insert/0:0/influx/write/write"

In this case, we can see it used the full path I had defined:

c, err := client.NewHTTPClient(client.HTTPConfig{
                Addr: fmt.Sprintf("http://%v:%v/insert/0:0/influx/write", hostname, port),
        })

Which leads me to believe the client is stripping any url prefix.

@vlastahajek
Copy link
Contributor

@johnseekins, thanks for posting the issue. Unfortunately, can confirm this a regression bug introduced in v1.1.0. If you use the client to write and query only, you can work around this by downgrading to v1.0.0

@vlastahajek vlastahajek self-assigned this Jul 9, 2020
@johnseekins
Copy link
Author

johnseekins commented Jul 9, 2020

Downgrading to 1.0.0 I still see this error.

(A bit of proof I am actually using 1.0.0):

$ cat go.mod 
module sisyphus

go 1.14

require (
        github.com/confluentinc/confluent-kafka-go v1.4.2
        github.com/influxdata/influxdb-client-go v1.0.0
        github.com/json-iterator/go v1.1.10
        github.com/pkg/profile v1.5.0
        github.com/sirupsen/logrus v1.6.0
        gopkg.in/yaml.v2 v2.3.0
)
$ cat go.sum 
github.com/confluentinc/confluent-kafka-go v1.4.2 h1:13EK9RTujF7lVkvHQ5Hbu6bM+Yfrq8L0MkJNnjHSd4Q=
github.com/confluentinc/confluent-kafka-go v1.4.2/go.mod h1:u2zNLny2xq+5rWeTQjFHbDzzNuba4P1vo31r9r4uAdg=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/influxdata/influxdb-client-go v1.0.0 h1:SfZUHnqqXn5oPoPZFt138NnFiQPLIgM9GZ3VOkj6ig4=
github.com/influxdata/influxdb-client-go v1.0.0/go.mod h1:9ESzlV5grLYaHA6wK2SSKlZr+gE3cxH2Q6pvRcASuVY=
github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839 h1:W9WBk7wlPfJLvMCdtV4zPulc4uCPrlywQOmbFOhgQNU=
github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo=
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/profile v1.5.0 h1:042Buzk+NhDI+DeSAA62RwJL8VAuZUMQZUjCsRz1Mug=
github.com/pkg/profile v1.5.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

@vlastahajek
Copy link
Contributor

Have you tried the V1 client with URL without the trailing /write?

c, err := client.NewHTTPClient(client.HTTPConfig{
     Addr: fmt.Sprintf("http://%v:%v/insert/0:0/influx", hostname, port),
})

@johnseekins
Copy link
Author

Yes. That does work (although it has some huge memory leaks). I was hoping to use v2 'cause it seemed the more supported solution, but...

@vlastahajek
Copy link
Contributor

And with the V2 client 1.0.0 you still see exactly the same error: unsupported path requested: "/api/v2/write", or sth else? 1.0.0 correctly accepts server URL with path..

@johnseekins
Copy link
Author

Exactly the same error, yes.

@johnseekins
Copy link
Author

Oh no! I didn't test that correctly!

@johnseekins
Copy link
Author

Never mind. 1.0.0 works perfectly fine. Thanks for the help.

@vlastahajek vlastahajek added this to the v1.4.0 milestone Jul 13, 2020
vlastahajek added a commit to bonitoo-io/influxdb-client-go that referenced this issue Jul 14, 2020
vlastahajek added a commit that referenced this issue Jul 15, 2020
fix: Allow connecting to a server on a URL path (#149)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants