Route calls to different trunks based on past usage

New user of Asterisk with FreePBX here.
I wonder if it’s possible to route outgoing calls to a specific trunk, based on a past usage of all the trunks.

For instance:
I have a specific destination that have certain monthly usage after which it becomes unavailable.
I would like to setup Asterisk to route the calls by default to Trunk1. Then, based on logs and monitored data of the monthly usage to reroute them to Trunk2 when certain threshold is passed. After a certain date, the calls are rerouted again through Trunk1 and the data is reset.

Another option would be to look for all the usage of given trunk for a specific period in the past and decide whether to route through Trunk1 or Trunk2 based on threshold.

Are there such functionalities build in Asterisk or are there similar modules?
Or you could just give me directions what capabilities of Asterisk should I use to implement it myself, since I am not familiar with all the options.

The third party FreePBX module, Trunk Balancing does most of what you are looking for:

installed it and will test it shortly. But it seems to be doing exactly what I need.