InfluxDB 2.x: CSV: Unterschied zwischen den Versionen

Aus Wiki-WebPerfect
Wechseln zu: Navigation, Suche
Zeile 38: Zeile 38:
 
</pre>
 
</pre>
  
'''Result:'''
+
'''Result:''' <br>
 
[[Datei:01-influxdb-flux-csv.png]] <br>
 
[[Datei:01-influxdb-flux-csv.png]] <br>
  

Version vom 5. Februar 2021, 10:55 Uhr

Work with a CSV in InfluxDB 2.x Explorer (from am exported query)

You can export queried data directly from InfluxDB 2.x Explorer with the button near the "Submit" button.
In this example, I show you how to easy work with exported CSV data without import it to your buckets

Exported data from InfluxDB 2.x Explorer:

#group,false,false,false,false,false,false,false,false,false,false
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string,string,string,double,double
#default,_result,,,,,,,,,
,result,table,_time,_start,_stop,_level,_measurement,host,threshold,value
,,0,2021-02-03T20:26:34Z,2021-02-03T19:48:56.599321105Z,2021-02-04T19:48:56.599321105Z,crit,host_cpu,host1,10,14
,,0,2021-02-03T20:26:49Z,2021-02-03T19:48:56.599321105Z,2021-02-04T19:48:56.599321105Z,crit,host_cpu,host2,10,12
,,0,2021-02-03T20:26:55Z,2021-02-03T19:48:56.599321105Z,2021-02-04T19:48:56.599321105Z,crit,host_cpu,host1,10,16
,,0,2021-02-03T20:26:44Z,2021-02-03T19:48:56.599321105Z,2021-02-04T19:48:56.599321105Z,ok,host_cpu,host1,10,2
,,0,2021-02-03T20:27:02Z,2021-02-03T19:48:56.599321105Z,2021-02-04T19:48:56.599321105Z,ok,host_cpu,host3,10,4
,,0,2021-02-03T20:28:55Z,2021-02-03T19:48:56.599321105Z,2021-02-04T19:48:56.599321105Z,crit,host_cpu,host1,10,16


Use the exported data (Explorer Query):

import "csv" //import the csv library

csvData = "
#group,false,false,false,false,false,false,false,false,false,false
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string,string,string,double,double
#default,_result,,,,,,,,,
,result,table,_time,_start,_stop,_level,_measurement,host,threshold,value
,,0,2021-02-03T20:26:34Z,2021-02-03T19:48:56.599321105Z,2021-02-04T19:48:56.599321105Z,crit,host_cpu,host1,10,14
,,0,2021-02-03T20:26:49Z,2021-02-03T19:48:56.599321105Z,2021-02-04T19:48:56.599321105Z,crit,host_cpu,host2,10,12
,,0,2021-02-03T20:26:55Z,2021-02-03T19:48:56.599321105Z,2021-02-04T19:48:56.599321105Z,crit,host_cpu,host1,10,16
,,0,2021-02-03T20:26:44Z,2021-02-03T19:48:56.599321105Z,2021-02-04T19:48:56.599321105Z,ok,host_cpu,host1,10,2
,,0,2021-02-03T20:27:02Z,2021-02-03T19:48:56.599321105Z,2021-02-04T19:48:56.599321105Z,ok,host_cpu,host3,10,4
,,0,2021-02-03T20:28:55Z,2021-02-03T19:48:56.599321105Z,2021-02-04T19:48:56.599321105Z,crit,host_cpu,host1,10,16
"
csv.from(csv: csvData)
//here you can use every Flux filters, functions & calculation you want

Result:
01-influxdb-flux-csv.png