-
Notifications
You must be signed in to change notification settings - Fork 177
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
Cannot invoke InfluxCloud 2.0 compatibility /query endpoint #536
Comments
Hey, i just stared with influxDB and found this issue. It looks like |
Influx 2.x offers a v1 compatibility endpoint for /query that I can consume using any http library, except, ironically this influx library. It would very much ease our migration to 2.x if we could maintain our current way of querying: using the same library and our InfluxQL queries, until we are able to move to the supported 2.x library (which is not able -to my knowledge- to use this compatibility endpoint with InfluxQL) with Flux queries |
This usually means that client that has connected is attempting to talk some protocol other than SSL/TLS - or sometimes that the data has been corrupted somehow (usually due to an application bug). Is it ok to use the port 80 and https at the same time? |
I modified a bit.. the auth option did not send correct Authorization token based header. Without username and empty password, the client used the default "root" and "root" credentials. const { InfluxDB: InfluxV1 } = require("influx")
const token = "influxdbv2token"
const v1Client = new InfluxV1({
// host: "westeurope-1.azure.cloud2.influxdata.com",
host: "us-central1-1.gcp.cloud2.influxdata.com",
username: "yourorganization",
// leave password empty
password: "",
port: 443,
protocol: "https",
options: {
headers: {
'Authorization' : `Token ${token}`
}
}
});
const rp = "demorp";
const db = "demo";
const q = `SELECT mean("capacity_pods") AS "mean_capacity_pods" FROM "${db}"."${rp}"."kubernetes_node" WHERE time > now() - 1d GROUP BY time(1h), "host" FILL(null)`
v1Client
.query(q, { precision: "ms", database: `${db}`, retentionPolicy: `${rp}` })
.then((results) => console.log(results))
.catch((err) => console.error("ERROR querying", err)) To create dbrp mapping: use the $ influx v1 dbrp list ....
ID Database Bucket ID Retention Policy Default Organization ID
06b7a28fff5dc000 demo 1d165103b59eb20e demorp true e81576123825396 To model InfluxQL use Chronograf v1 (1.8.9.1 has ootb support for connecting to Cloud2). This worked for me.. I hope this helps. For 2.0 servers consider using https://github.com/influxdata/influxdb-client-js |
I will try that later in the day and report what the results will be. |
That totally worked! Thanks for that, it is not very not intuitive:
BTW, I found out that only The port has to be indeed 443, not 80 as I was passing. This v1 client works just fine: const v1Client = new InfluxV1({
host: "westeurope-1.azure.cloud2.influxdata.com",
port: 443,
protocol: "https",
password: null,
options: { headers: { Authorization: `Token ${token}` } },
database
}) |
Expected Behavior
To be able to call the compatibility /query endpoint to get results from InfluxCloud 2.0 using 1.x javascript client and InfluxQL while we migrate our code to 2.x javascript client and Flux.
Actual Behavior
And error when performing the query:
Steps/Code to Reproduce the Problem
Specifications
Extra information
I am able to perform the query using HTTP, both in a REST client and using axios, but not using the influx client:
The text was updated successfully, but these errors were encountered: