Title: | R Interface to InfluxDB |
---|---|
Description: | An R interface to the InfluxDB time series database <https://www.influxdata.com>. This package allows you to fetch and write time series data from/to an InfluxDB server. Additionally, handy wrappers for the Influx Query Language (IQL) to manage and explore a remote database are provided. |
Authors: | Dominik Leutnant [aut, cre] |
Maintainer: | Dominik Leutnant <[email protected]> |
License: | GPL-3 |
Version: | 0.14.4.9000 |
Built: | 2025-02-16 03:15:52 UTC |
Source: | https://github.com/dleutnant/influxdbr |
The folllowing functions are convenient wrappers around influx_post
.
create_database()
: creates a new database
drop_database()
: drops an existing database
drop_series()
: drops specific series
delete()
: deletes all points from a series in a database (supports time intervals)
drop_measurement()
: drops an entire measurement
create_retention_policy()
: create a new retention policy
alter_retention_policy()
: alter a retention policy
drop_retention_policy()
: drop a retention policy
create_database(con, db) drop_database(con, db) drop_series(con, db, measurement = NULL, where = NULL) delete(con, db, measurement = NULL, where = NULL) drop_measurement(con, db, measurement) create_retention_policy( con, db, rp_name, duration, replication, default = FALSE ) alter_retention_policy( con, db, rp_name, duration, replication, default = FALSE ) drop_retention_policy(con, db, rp_name)
create_database(con, db) drop_database(con, db) drop_series(con, db, measurement = NULL, where = NULL) delete(con, db, measurement = NULL, where = NULL) drop_measurement(con, db, measurement) create_retention_policy( con, db, rp_name, duration, replication, default = FALSE ) alter_retention_policy( con, db, rp_name, duration, replication, default = FALSE ) drop_retention_policy(con, db, rp_name)
con |
An |
db |
Sets the target database for the query. |
measurement |
Sets a specific measurement. |
where |
Apply filter on tag key values. |
rp_name |
The name of the retention policy. |
duration |
Determines how long InfluxDB keeps the data. |
replication |
The number of data nodes. |
default |
logical. If TRUE, the new retention policy is the default retention policy for the database. |
A tibble containing post results in case of an error (or message). Otherwise NULL (invisibly).
https://docs.influxdata.com/influxdb/
The folllowing functions are convenient wrappers around influx_post
and influx_query
(show_users and show grants).
create_user()
: creates a new user
drop_user()
: drops an existing user
grant_privileges()
: grant privileges to an existing users
revoke_privileges()
: revoke privileges to an existing users
show_users()
: show all users
show_grants()
: show grants of an user
create_user(con, username, password) drop_user(con, username) grant_privileges(con, privilege = c("READ", "WRITE", "ALL"), db, username) revoke_privileges(con, privilege = c("READ", "WRITE", "ALL"), db, username) show_users(con) show_grants(con, username)
create_user(con, username, password) drop_user(con, username) grant_privileges(con, privilege = c("READ", "WRITE", "ALL"), db, username) revoke_privileges(con, privilege = c("READ", "WRITE", "ALL"), db, username) show_users(con) show_grants(con, username)
con |
An |
username |
The username to be used. |
password |
The password to be used. |
privilege |
Specifies the user privilege. |
db |
Sets the target database. |
A tibble containing post results in case of an error (or message).
Otherwise NULL (invisibly). show_users()
and show_grants()
return a tibble.
https://docs.influxdata.com/influxdb/
Create an influxdb_connection object by specifying server connection details. Credentials can also be saved and accessed through a config file.
influx_connection( scheme = c("http", "https"), host = "localhost", port = 8086, user = "user", pass = "pass", path = "/", group = NULL, verbose = FALSE, config_file = "~/.influxdb.cnf", curl_options = NULL )
influx_connection( scheme = c("http", "https"), host = "localhost", port = 8086, user = "user", pass = "pass", path = "/", group = NULL, verbose = FALSE, config_file = "~/.influxdb.cnf", curl_options = NULL )
scheme |
The scheme to use, either http or https. Defaults to http. |
host |
Hostname of the InfluxDB server. Defaults to localhost. |
port |
numerical. Port number of the InfluxDB server. Defaults to 8086. |
user |
username The username to use. Defaults to "user". |
pass |
password The password to use. Defaults to "pass". |
path |
The prefix path on which the InfluxDB is running. Can be useful in proxy situations. |
group |
The group to use within the config file. |
verbose |
logical. Provide additional details? |
config_file |
The configuration file to be used if |
curl_options |
Additional curl arguments created with |
A configuration file may contain several connection settings. Each setting
has the following structure:
[group] scheme=http host=localhost port=8086 user=username pass=password path=/
This function pings an influxdb server (e.g. for connection testing)
influx_ping(con)
influx_ping(con)
con |
An |
A tibble with server information.
https://docs.influxdata.com/influxdb/
This functions queries an InfluxDB server.
influx_query( con, db = NULL, query = "SELECT * FROM measurement", timestamp_format = c("n", "u", "ms", "s", "m", "h"), return_xts = TRUE, chunked = FALSE, simplifyList = FALSE )
influx_query( con, db = NULL, query = "SELECT * FROM measurement", timestamp_format = c("n", "u", "ms", "s", "m", "h"), return_xts = TRUE, chunked = FALSE, simplifyList = FALSE )
con |
An |
db |
Sets the target database for the query. |
query |
The InfluxDB query to be sent. |
timestamp_format |
Sets the timestamp format ("n", "u", "ms", "s", "m", "h"). |
return_xts |
logical. Sets the return type. If set to TRUE, xts objects are returned, FALSE gives tibbles. |
chunked |
Either FALSE or an integer. If FALSE, series are not requested
in streamed batches. If an integer is provided, responses will be chunked by
series or by every |
simplifyList |
logical. If only one series is returned, the result can be flatten to directly get either a tibble or an xts object (instead of a list) (default is FALSE). |
A list of tibble or xts objects. Empty query results yield to NULL.
https://docs.influxdata.com/influxdb/
This function is a convenient wrapper for selecting data from a measurement
by calling influx_query
with the corresponding query.
influx_select( con, db, field_keys, rp = NULL, measurement, where = NULL, group_by = NULL, limit = NULL, slimit = FALSE, offset = NULL, order_desc = FALSE, return_xts = TRUE, simplifyList = FALSE )
influx_select( con, db, field_keys, rp = NULL, measurement, where = NULL, group_by = NULL, limit = NULL, slimit = FALSE, offset = NULL, order_desc = FALSE, return_xts = TRUE, simplifyList = FALSE )
con |
An |
db |
Sets the target database for the query. |
field_keys |
Specifies the fields to be selected. |
rp |
The name of the retention policy. |
measurement |
Character vector containing name(s) of the measurement(s). |
where |
Apply filter on tag key values. |
group_by |
The group_by clause in InfluxDB is used not only for grouping by given values, but also for grouping by given time buckets. |
limit |
Limits the number of the n oldest points to be returned. |
slimit |
logical. Sets limiting procedure (slimit vs. limit). |
offset |
Offsets the returned points by the value provided. |
order_desc |
logical. Change sort order to descending. |
return_xts |
logical. Sets the return type. If set to TRUE, a list of xts objects is returned, FALSE gives list of tibbles. |
simplifyList |
logical. If only one series is returned, the result can be flatten to directly get either a tibble or an xts object (instead of a list) (default is FALSE). |
A list of xts or tibbles. Empty query results yield to NULL.
https://docs.influxdata.com/influxdb/
This function writes either an xts
object or a data.frame
to an InfluxDB server.
In case of an xts object, columnnames of the xts
object are used as InfluxDB's field keys,
xts
's coredata represent field values. Attributes are preserved and written
as tag keys and values, respectively.
In case of a data.frame
, columns may represent times and both tag and field values.
Columnnames of the data.frame
object are used as InfluxDB's tag and field keys.
Times and tags are optional. Use parameter time_col
and tag_col
to define
the interpretation. By specifiying one of the arguments measurement
or measurement_col
,
a data.frame may contain data from one measurement or multiple measurements, respectively.
influx_write( x, con, db, measurement, rp = NULL, precision = c("s", "ns", "u", "ms", "m", "h"), consistency = c(NULL, "one", "quroum", "all", "any"), max_points = 5000, use_integers = FALSE, ... ) ## S3 method for class 'xts' influx_write( x, con, db, measurement, rp = NULL, precision = c("s", "ns", "u", "ms", "m", "h"), consistency = c(NULL, "one", "quroum", "all", "any"), max_points = 5000, use_integers = FALSE, ... ) ## S3 method for class 'data.frame' influx_write( x, con, db, measurement = NULL, rp = NULL, precision = c("s", "ns", "u", "ms", "m", "h"), consistency = c(NULL, "one", "quroum", "all", "any"), max_points = 5000, use_integers = FALSE, time_col = NULL, tag_cols = NULL, measurement_col = NULL, ... )
influx_write( x, con, db, measurement, rp = NULL, precision = c("s", "ns", "u", "ms", "m", "h"), consistency = c(NULL, "one", "quroum", "all", "any"), max_points = 5000, use_integers = FALSE, ... ) ## S3 method for class 'xts' influx_write( x, con, db, measurement, rp = NULL, precision = c("s", "ns", "u", "ms", "m", "h"), consistency = c(NULL, "one", "quroum", "all", "any"), max_points = 5000, use_integers = FALSE, ... ) ## S3 method for class 'data.frame' influx_write( x, con, db, measurement = NULL, rp = NULL, precision = c("s", "ns", "u", "ms", "m", "h"), consistency = c(NULL, "one", "quroum", "all", "any"), max_points = 5000, use_integers = FALSE, time_col = NULL, tag_cols = NULL, measurement_col = NULL, ... )
x |
The object to write to an InfluxDB server (either of class |
con |
An |
db |
Sets the target database for the query. |
measurement |
Sets the name of the measurement (data.frame has data to
write to one measurement only). If both arguments |
rp |
Sets the target retention policy for the write. If not present the default retention policy is used. |
precision |
Sets the precision of the supplied Unix time values ("s", "ns", "u", "ms", "m", "h"). If not present timestamps are assumed to be in seconds. |
consistency |
Set the number of nodes that must confirm the write. If the requirement is not met the return value will be partial write if some points in the batch fail, or write failure if all points in the batch fail. |
max_points |
Defines the maximum points per batch (defaults to 5000). |
use_integers |
Should integers (instead of doubles) be written if present? |
... |
Arguments to be passed to methods. |
time_col |
A character scalar naming the time index column. |
tag_cols |
A character vector naming tag columns. |
measurement_col |
A character scalar naming the measurement column
(data.frame has data to write to multiple measurements). Overrides
|
A list of server responses.
https://docs.influxdata.com/influxdb/
The folllowing functions are convenient wrappers around influx_query
.
show_databases()
: returns database names
show_measurements()
: returns measurement names
show_series()
: returns unambiguous series
show_tag_keys()
: returns tag keys
show_tag_values()
: returns tag values
show_field_keys()
: returns field keys
show_retentions_policies()
: returns retention policies
show_databases(con) show_measurements(con, db, where = NULL) show_series(con, db, measurement = NULL, where = NULL) show_tag_keys(con, db, measurement = NULL) show_tag_values(con, db, measurement = NULL, key) show_field_keys(con, db, measurement = NULL) show_retention_policies(con, db)
show_databases(con) show_measurements(con, db, where = NULL) show_series(con, db, measurement = NULL, where = NULL) show_tag_keys(con, db, measurement = NULL) show_tag_values(con, db, measurement = NULL, key) show_field_keys(con, db, measurement = NULL) show_retention_policies(con, db)
con |
An |
db |
Sets the target database for the query. |
where |
Apply filter on tag key values. |
measurement |
Query a specific measurement. |
key |
The key to be queried. |
A tibble containing query results.
https://docs.influxdata.com/influxdb/
This function calls influx_query
to receive some diagnostics.
show_diagnostics(con)
show_diagnostics(con)
con |
An |
A tibble with diagnostics.
This function calls influx_query
to receive some stats.
show_stats(con)
show_stats(con)
con |
An |
A tibble.
InfluxDB response might take some time.