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

InfluxDB 2.0 support #66

Open
G9A2HvK9 opened this issue Nov 23, 2019 · 18 comments
Open

InfluxDB 2.0 support #66

G9A2HvK9 opened this issue Nov 23, 2019 · 18 comments

Comments

@G9A2HvK9
Copy link

G9A2HvK9 commented Nov 23, 2019

Hi Dominik,

Ich beschäftige mich ehrlicher Weise gerade zum ersten Mal mit diesr Thematik. Ich versuche ein Influx DB mit R Studio zu verbinden. Das Influx DB läuft derzeit auf der Influx Cloud. Dazu lasse ich folgenden Code laufen:

library(dplyr)
library(influxdbr)
library(xts)
library(rjson)
library(jsonlite)

influxdb_connection <- influx_connection(scheme = c("http", "https"), host = "host-address.com/", port = 8086, user = "XXX", pass = "XXX", path = "/", group = NULL, verbose = FALSE, config_file = "~/.influxdb.cnf", curl_options = NULL)

Success: (200) OK

show_databases(con = influxdb_connection)

Error: lexical error: invalid char in json text.
                                       <!doctype html><html><head><scr
                     (right here) ------^

Habe versucht verschiedene JSON leser auf das Ergebnisse anzusetzen. Bisher ohne Erfolg. ist hier etwas grundlegend falsch?

debug gibt folgendes Ergebnis:

20. parse_string(txt, bigint_as_char) 
19. parseJSON(txt, bigint_as_char) 
18. parse_and_simplify(txt = txt, simplifyVector = simplifyVector, 
    simplifyDataFrame = simplifyDataFrame, simplifyMatrix = simplifyMatrix, 
    flatten = flatten, ...) 
17. .f(.x[[i]], ...) 
16. purrr::map(x, jsonlite::fromJSON, simplifyVector = FALSE, simplifyDataFrame = FALSE, 
    simplifyMatrix = FALSE) 
15. .f(.x[[i]], ...) 
14. purrr::map(., response_to_list) 
13. function_list[[i]](value) 
12. freduce(value, `_function_list`) 
11. `_fseq`(`_lhs`) 
10. eval(quote(`_fseq`(`_lhs`)), env, env) 
9. eval(quote(`_fseq`(`_lhs`)), env, env) 
8. withVisible(eval(quote(`_fseq`(`_lhs`)), env, env)) 
7. rawToChar(response$content) %>% purrr::map(response_to_list) %>% 
    purrr::map(query_list_to_tibble, timestamp_format = timestamp_format) %>% 
    purrr::flatten(.) 
6. influx_query(con = con, query = "SHOW DATABASES", return_xts = FALSE) 
5. eval(lhs, parent, parent) 
4. eval(lhs, parent, parent) 
3. influx_query(con = con, query = "SHOW DATABASES", return_xts = FALSE) %>% 
    purrr::map_df(~dplyr::select(., name)) 
2. show_databases(con = influxdb_connection) 
1. my_test_function() 

Danke und VG.

@dleutnant
Copy link
Owner

Could you please set scheme = "https"and try again?

@dleutnant
Copy link
Owner

Also, what is the result of the following code (please change scheme, hostname and port accordingly) ?

library(httr)
res <- GET(url = "", 
           scheme = "https", 
           hostname = "host-address.com",
           port = 8086, 
           path = "/ping")

res$all_headers

@dleutnant
Copy link
Owner

... which version of {influxdbr} do you use?

packageVersion("influxdbr")

@dleutnant
Copy link
Owner

... and of course your sessionInfo() could be helpful ;)

@G9A2HvK9
Copy link
Author

G9A2HvK9 commented Dec 3, 2019

Could you please set scheme = "https"and try again?

Error: lexical error: invalid char in json text.
<!doctype html><scr
(right here) ------^

@G9A2HvK9
Copy link
Author

G9A2HvK9 commented Dec 3, 2019

Also, what is the result of the following code (please change scheme, hostname and port accordingly) ?

library(httr)
res <- GET(url = "", 
           scheme = "https", 
           hostname = "host-address.com",
           port = 8086, 
           path = "/ping")

res$all_headers

[[1]]
[[1]]$status
[1] 200

[[1]]$version
[1] "HTTP/2"

[[1]]$headers
$date
[1] "Tue, 03 Dec 2019 15:12:29 GMT"

$content-type
[1] "text/html"

$last-modified
[1] "Mon, 25 Nov 2019 20:39:29 GMT"

$etag
[1] "W/"5ddc3c01-3ae""

$content-encoding
[1] "gzip"

$strict-transport-security
[1] "max-age=15724800; includeSubDomains"

attr(,"class")
[1] "insensitive" "list"

@G9A2HvK9
Copy link
Author

G9A2HvK9 commented Dec 3, 2019

... which version of {influxdbr} do you use?

packageVersion("influxdbr")

packageVersion('influxdbr')
[1] ‘0.14.2’

@G9A2HvK9
Copy link
Author

G9A2HvK9 commented Dec 3, 2019

... and of course your sessionInfo() could be helpful ;)

R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.1

Matrix products: default
BLAS: ***/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: ***/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] httr_1.4.1 jsonlite_1.6 rjson_0.2.20 xts_0.11-2 zoo_1.8-6 influxdbr_0.14.2 dplyr_0.8.3

loaded via a namespace (and not attached):
[1] Rcpp_1.0.2 lattice_0.20-38 crayon_1.3.4 assertthat_0.2.1 grid_3.6.1 R6_2.4.0 magrittr_1.5 pillar_1.4.2 rlang_0.4.0 curl_4.2 rstudioapi_0.10 tools_3.6.1
[13] glue_1.3.1 purrr_0.3.3 compiler_3.6.1 pkgconfig_2.0.3 tidyselect_0.2.5 tibble_2.1.3

@dleutnant
Copy link
Owner

Thanks. Do you know which InfluxDB is behind InfluxDB Cloud (i.e. 1.x or 2.0)? influxdbr is currently not compatible with InfluxDB 2.0 (but I am in contact with InfluxData).

@G9A2HvK9
Copy link
Author

G9A2HvK9 commented Dec 6, 2019

No probs. Thank you! The InfluxDB Cloud is using 2.0 -- I guess this means we're at an impass here. Would love an update if / when you manage to integrate.

Thanks for all your work in this package. It's really interesting, and I'm sure it'll be super useful once I can get our InfluxDB to run.

@dleutnant dleutnant changed the title MacOS 10.15 // R Version 3.6.1 // show_databases returning lexical error // Error: lexical error: invalid char in json text. <!doctype html><html><head><scr (right here) InfluxDB 2.0 support Dec 6, 2019
@FixTestRepeat
Copy link

Any news on influxdb v2 compatibility?

@dleutnant
Copy link
Owner

no

@nickcardamone
Copy link

Hi. Thank you for your work on this package, it's extremely helpful. Is there any info about when Influx 2.0 compatibility might come?

@dleutnant
Copy link
Owner

dleutnant commented Jan 12, 2021

Thanks. Unfortunately, I won‘t work on this. Please see my response to #63.

@bilbaoba
Copy link

bilbaoba commented Feb 4, 2021

@dleutnant, can you explain briefly what we have to do to support InfluxDB 2.0 ?

@dleutnant
Copy link
Owner

@bilbaoba Well, I'd suggest to contact people at InfluxData and seek for some guidance in this respect. My experience with InfluxDB is limited to the 1.x versions.

@riedel
Copy link

riedel commented Apr 25, 2021

InfluxDB 2 has a completely different interface, however, it has a backward compatibility layer below /query and /write . I managed to debug the problem by using httr::set_config(verbose()) and trying out the queries using curl. For me the nastiest part was getting authentication to work. First tried the token scheme, but this does not work since influxdbr always emits user name and password even if not set. So one has to create an auth user.

see docs here: https://docs.influxdata.com/influxdb/v2.0/upgrade/v1-to-v2/manual-upgrade/

Other than that one needs to create a mapping for influx 1 DBs to influx 2 buckets manually, which is also described.

The 2.0 API is totally different and uses a different query language (flux), so I would really suggest a fork of the library instead of generating compat interfaces (one in the client and one in the server)

Seems that it works for me now including the show_databases(con).

@rbetts
Copy link

rbetts commented May 17, 2021

(I work for Influxdata.)

InfluxDB 2 has a completely different interface, however, it has a backward compatibility layer below /query and /write

This is correct. The client should work for basic write and query endpoints against 2.x. The compatibility endpoints (including for influxql) are documented here: https://docs.influxdata.com/influxdb/cloud/reference/api/influxdb-1x/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants