strittmm
strittmm

Reputation: 33

InfluxDB v2 annotated csv in R

InfluxDB and Flux return query results in annotated CSV format. Im am querying the data from R studio using the InfluxDB v2 API. How do I work with the data I receive in the annotated csv format?

Annotated csv:

#group,false,false,true,true,false,false,true,true,true,true
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string
#default,_result,,,,,,,,,
,result,table,_start,_stop,_time,_value,_field,_measurement,equipmentNumber,workplace
,,0,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:14:48.74Z,1,MONITORING,MONITORING,L4212M1017,1
,,0,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:18:23.238Z,0,MONITORING,MONITORING,L4212M1017,1
,,0,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:18:39.918Z,1,MONITORING,MONITORING,L4212M1017,1

#group,false,false,true,true,false,false,true,true,true,true
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string
#default,_result,,,,,,,,,
,result,table,_start,_stop,_time,_value,_field,_measurement,equipmentNumber,workplace
,,1,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:18:44.53Z,0,MONITORING,MONITORING,L4212M1017,2

#group,false,false,true,true,false,false,true,true,true,true
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string
#default,_result,,,,,,,,,
,result,table,_start,_stop,_time,_value,_field,_measurement,equipmentNumber,workplace
,,2,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:17:57.538Z,0,MONITORING,MONITORING,L4212M1017,3
,,2,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:18:17.006Z,1,MONITORING,MONITORING,L4212M1017,3

#group,false,false,true,true,false,false,true,true,true,true
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string
#default,_result,,,,,,,,,
,result,table,_start,_stop,_time,_value,_field,_measurement,equipmentNumber,workplace
,,3,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:14:48.74Z,1,MONITORING,MONITORING,L4212M1017,4
,,3,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:17:57.538Z,0,MONITORING,MONITORING,L4212M1017,4
,,3,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:18:17.007Z,1,MONITORING,MONITORING,L4212M1017,4
,,3,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:18:23.239Z,0,MONITORING,MONITORING,L4212M1017,4
,,3,2017-06-27T03:14:48.74Z,2017-06-27T04:16:58.278Z,2017-06-27T03:18:39.919Z,1,MONITORING,MONITORING,L4212M1017,4

Does anyone have any experience with Influx and R?

Upvotes: 0

Views: 397

Answers (1)

alespour
alespour

Reputation: 465

You could try to use InfluxDB 2.0 R client:

library(influxdbclient)

client <- InfluxDBClient$new(
    url = "http://localhost:8086",
    token = "my-token",
    org = "my-org")
                    
data <- client$query('from(bucket: "my-bucket") |> range(start: -1h)')

Upvotes: 2

Related Questions