| InfluxDBClient | R Documentation |
Client for querying from and writing to InfluxDB 2.x.
An R6Class object
urlDatabase URL
tokenAuthentication token
orgOrganization name
dialectFlux dialect
retryOptionsRetry options
new()Creates instance of InfluxDBClient.
InfluxDBClient$new(url, token, org, retryOptions = NULL)
urlInfluxDB instance URL
tokenAuthentication token
orgOrganization name
orgRetry options. See RetryOptions for details. Set to TRUE
for default retry options. Default is NULL which disables retries.
health()Gets health info of the InfluxDB instance.
InfluxDBClient$health()
Named list with name, message, status,
version, commit elements or error
query()Queries data in the InfluxDB instance.
InfluxDBClient$query( text, POSIXctCol = c(`_time` = "time"), flatSingleResult = TRUE )
textFlux query
POSIXctColFlux time to (new) POSIXct column mapping (named list).
Default is c("_time"="time"). Use NULL to skip it.
flatSingleResultWhether to return simple list when response contains
only one result. Default is TRUE.
List of data frames. Data frame represents Flux table. It can be a named list of nested lists of data frames when query response contains multiple results (see Flux yield), or a simple list of data frames for single result response.
ready()Gets readiness status of the InfluxDB instance.
InfluxDBClient$ready()
Named list with status, started and up elements or error
write()Writes data to the InfluxDB instance.
InfluxDBClient$write(
x,
bucket,
batchSize = 5000,
precision = c("ns", "us", "ms", "s"),
measurementCol = "_measurement",
tagCols = NULL,
fieldCols = c(`_field` = "_value"),
timeCol = "_time",
object = NULL,
...
)xData as (list of) data.frame
bucketTarget bucket name
batchSizeBatch size. Positive number or FALSE to disable.
Default is 5000.
precisionTime precision
measurementColName of measurement column. Default is "_measurement".
tagColsNames of tag (index) columns
fieldColsNames of field columns. In case of unpivoted data
previously retrieved from InfluxDB, use default value ie. named list
c("_field"="_value").
For all other cases, just use simple vector of column names (see Examples).
timeColName of time column. The column values should be either
of nanotime or POSIXct type. Default is "_time".
objectOutput object name. For dry-run operation, specify the name
of the object to receive the output. Default is NULL. For debugging purposes.
clone()The objects of this class are cloneable with this method.
InfluxDBClient$clone(deep = FALSE)
deepWhether to make a deep clone.
## Not run:
# Instantiation
client <- InfluxDBClient$new(url = "http://localhost:8086",
token = "my-token",
org = "my-org")
# Query
data <- client$query('from(bucket: "my-bucket") |> range(start: -1h)')
# Write
data <- data.frame(...)
client$write(data, bucket = "my-bucket", precision = "us",
measurementCol = "name",
tagCols = c("location", "id"),
fieldCols = c("altitude", "temperature"),
timeCol = "time")
# Ready status
ready <- client$ready()
# Healt info
ready <- client$health()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.