Access timestamps in UDF to do adaptive sampling and storage

Hello All,
I am working on a problem where I have to dynamically remove certain points using a logic.
Say i have data stored at 1 sample per second, i wish to run a kapacitor task that queries data in 10 min windows , then according to the logic retains some 20-30 points out of 600 and writes to some other database retaining their timestamp. I need control on the timestamp of the time series data in my UDF and also ability to only write selected points back. since number of points written back changes every 10 minute window.