Q:  Is the event table in IMDC (postgresql database) govern by retention policies?  If not, are there any way to get custom scripts to run periodically to clean up the table?

A:  Currently, no, retention policies don't govern events. That capability is something we're planning to add, though, as we see customer databases growing larger. It will likely take the form of an additional setting for each policy, just like the existing raw/5-minute/hourly/daily settings.  Until then you can delete events past a certain age via the maintenance page, but there's no way to schedule that action.

What you could do is take advantage of the fact that the database automatically refreshes its caches whenever IM restarts. So you could have the cron job stop the IM server(s) reporting to the database, run the query, then start the IM server(s) again. But that isn't perfect either, since it leaves a small gap in monitoring, and may trigger alerts and other undesirable behavior as a result of the restart.

Approaching it another way, if the cron job ran the query and then immediately restarted IMDC, that would also reload the caches, though it still leaves a small window in which it's possible to get import errors.

The only fully reliable solution is to write a script that issues an HTTP POST to run the delete-old-events action on the maintenance page, but even that is very much a work-around, not a permanent solution.