0

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?

strittmm
  • 53
  • 1
  • 8
  • I am using influxr package and I have posted this question: https://stackoverflow.com/questions/69040375/writing-dates-with-influxr-write-to-influxdb . Are you using Influxdb API? – learning-man Sep 03 '21 at 11:08

1 Answers1

2

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)')
alespour
  • 397
  • 1
  • 5