UDF to query/visualize data over time

We are using Aerospike as a timeseries database (with time started and time end bins). I’m trying to understand how much data we have stored over time, so that I can see what the effect would be of applying a TTL. Can anyone help me with a UDF that aggregates the number of records by namespace/set over time (perhaps by month)?