Hello @Anaisdg and sorry for the late response.
My use case is easy. I need compute %OK vs % NOK from some k8s deployed services monitored by somebody ( not me) with prometheus and alertmanager.
The only data I have Is events service_id: timestamp: OK
or service_id: timestamp: NO-OK
in a sql database where I can access.
I think the example in the traces lib is enouth good , changing 0 by NO OK and 1 by OK.
>>> time_series = traces.TimeSeries()
>>> time_series[datetime(2042, 2, 1, 6, 0, 0)] = 0 # 6:00:00am
>>> time_series[datetime(2042, 2, 1, 7, 45, 56)] = 1 # 7:45:56am
>>> time_series[datetime(2042, 2, 1, 8, 51, 42)] = 0 # 8:51:42am
>>> time_series[datetime(2042, 2, 1, 12, 3, 56)] = 1 # 12:03:56am
>>> time_series[datetime(2042, 2, 1, 12, 7, 13)] = 0 # 12:07:13am
>>>
>>> time_series.distribution(
>>> start=datetime(2042, 2, 1, 6, 0, 0), # 6:00am
>>> end=datetime(2042, 2, 1, 13, 0, 0) # 1:00pm
>>> )
Histogram({0: 0.8355952380952381, 1: 0.16440476190476191})
In this case this service was OK 16% time and 83 time NO-OK b/etween 6:00am and 1:pm.
If I can schedule this calculation periodically over time with predefined time slots (1h/1d/1week/1month) I will be able to compute time based SLA’s to any external service in this way.
The alternative with elapsed/map seems too difficult, I think a good idea if flux could have a special function to compute this kind of distribution data.
thank you very much.