Created
January 8, 2021 02:42
-
-
Save alsargent/0e2d6b4508a0870fcd2b63c9b1106ca0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// subDuration explained at: https://docs.influxdata.com/influxdb/v2.0/reference/flux/stdlib/experimental/subduration/ | |
// date.truncate explained at: https://docs.influxdata.com/influxdb/v2.0/reference/flux/stdlib/date/truncate/ | |
import "date" | |
import "csv" | |
import "experimental" | |
csvData = " | |
#datatype,string,long,dateTime:RFC3339,string,string,double | |
#group,false,false,false,false,false,false | |
#default,,,,,, | |
,result,table,_time,region,host,_value | |
,mean,0,2021-01-05T20:50:00Z,east,A,15.43 | |
,mean,0,2021-01-06T10:50:20Z,east,B,59.25 | |
,mean,0,2021-01-07T20:50:20Z,east,D,49.25 | |
,mean,0,2021-01-07T20:50:40Z,east,C,52.62 | |
" | |
data = csv.from(csv: csvData) | |
today = experimental.subDuration( | |
d: 8h, | |
from: date.truncate(t: now(), unit: 1d), | |
) | |
data | |
|> range(start: today) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment