We have our UniFi Controller that has a large number of old client devices still showing under Clients menu and I want to flush these out of the system as they are no longer required.

The Statistics menu has a "Clear All Statistics" button but this only flushes the current usage statistics.

How do I remove all the old details as well?


The following link allows you to prune all the statistics and old users

but if you are having issues we have simplified the issue for you.

Attached is a zip file that should be extracted to "c:\prune" directory.

Once extracted:

* Edit the "mongo_prune_js.js" file with any text editor and change the "var days=x" value to the number of previous days to prune.

* Run the "delete_stats.bat" file.

This will remove all old statistics & users and clean up the database.

Once it has finished stop and restart the UniFi Controller.

You should now see all the old statistics have been removed.


You must have the Controller running when running the batch file.

You should make a backup of your UniFi Controller before running this script.

This is based on the 64bit version of MongoDB msi