influxr_select: Selects data points from an InfluxDB database.

Description Usage Arguments Details Examples

Description

'influxr_select' returns the result of a query.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
influxr_select(
  client,
  database,
  measurement = "",
  fields = "*",
  from = NULL,
  to = NULL,
  tags = NULL,
  group_by = NULL,
  aggregation = NULL,
  fill = NULL,
  missing = c(-9999, -9999.99, -9999.9999),
  missing_replacement = NA,
  limit = 1e+06,
  desc = FALSE,
  extra_conditions = NULL,
  ...
)

Arguments

client

Influx_client object created with influxr_connection

database

character string. Database name.

measurement

character string. InfluxDb measurement name.

fields

character vector, NULL or "*". Fields to be selected eg. c('T','Humidity', 'w'). NULL or '*' will select all fields.

from

'POSIX' datetime or character in ISO8601 format which will be parsed to date time eg. '2017-12-31 14:00:00' or simply '2017' for the start of 2017. if NULL all values will be selected.

to

POSIX datetime or character in ISO8601 format which will be parsed to date time eg. '2017-12-31 14:00:00' or simply '2017' for the start of 2017. if NULL all values will be selected. Note: influxr_select returns data points in the range [from, to[, ie: where time >= from and time < to.

tags

named character vector. Only data points tagged with provided tags will be fetched. eg. c(station = 'Hainich', level = 3, method = 'EC').

group_by

character string. How data points should be grouped when an aggregation function is specified, possible values are 'time(1h)' to aggregate by time, or any other time interval or other field. If NULL no grouping will happen.

fill

character string. How should empty datapoints be filled, default to 'null' other possible options are "linear", "none", "null" or "previous"

limit

numeric. How many data points should the result be limited to. If NULL or Inf everything will be returned. Default to one million data points.

desc

logical, not emplemented yet.

extra_conditions

Pass extra conditions to the query.

...

passed to ‘influxr_query'. e.g. 'write_to_file = ’~/test.csv''

aggreagation

character string. Aggregation function to be used. Currently supported functions are 'MEAN','COUNT','DISTINCT', 'INTEGRAL','MEDIAN','MODE', 'SPREAD','STDDEV','SUM', 'FIRST','LAST', 'MIN', 'MAX' if NULL no aggregation is performed.

Details

other options that can be passed to the function are ignore_names and ignore_tags.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Read data from InfluxDB instance and store the result in timed rotating 

## Not run: 

influxr_select(
  influxdb_connection,
  database,
  measurement = 'cpu',
  tags = c(level = 1, station = 'work'),
  verbose = TRUE,
  from = '2017-07-10 12:00:00',
  to = '2017-08-10 12:00:00',
  write_handler = save_timed_rotating_files,
  path = my_path,
  base_file_name = 'cpu_',
  rotation_interval = '1 week',
  trunc_start = TRUE
)

## End(Not run)

influxr/influxr documentation built on Aug. 5, 2020, 9:03 p.m.