I need some help on how to write query in flux in golang which can select/delete data on a particular time and not time range
I understand the range function as explained in range() function | Flux Documentation
but unfortunately I am not able to use a specific time in the query. I tried using start and stop with same value(like below) but it does not work.
For example , I want to see data with only timestamp 2023-12-01T21:30:50Z
Below query gives error " error in building plan while starting program: cannot query an empty range"
|> range(start: 2023-12-01T21:30:50Z, stop: 2023-12-01T21:30:50Z)
And The below query yeilds nothing
|> range(start: 2023-12-01T21:30:50Z, stop: 2023-12-01T21:30:51Z)
|> filter(fn: (r) => r[“_time”]== 2023-12-01T21:30:50Z)
However, if filter is removed I can see some data.
Thanks , formatting is fine - this above output was what I was wondering to see. This isn’t a style I recognize - maybe unique to the Golang plugin . Given the behavior you’re getting it makes me think there is extra time precision in these records that isn’t visible. ( The start time would be treated internally as 2023-12-01T21:30:50.000000000Z)
Without knowing your use case, if you’re expecting a single record to be returned when you use the 1 second range query,instead of using the final pipe into filter, you could pipe into first()
The second query with a stop value one second more(2023-12-01T21:30:51Z) than the start (2023-12-01T21:30:50Z)was for testing purpose. I wanted to see if the records with time 2023-12-01T21:30:50Z is correctly fetched and yes it was fetching . Ofcourse the query also included the records with time 2023-12-01T21:30:51Z and surely I dont want that. I only want to fetch the records for the specific time 2023-12-01T21:30:50Z.
Well, I was not able to execute a query without using range. Can you please provide an example.
However, I did try using range first and then filter on the specfic time and the there was no result
3. Query: