Setting to regularly purge query log after a period eg 3 months [Suggestion]

What: Have a setting that allows the user to set an interval for purging query data that is older than the specified period. This would be a different setting to the anonymous query logging.

How: At a 24 hour interval (same time as one that handles log rotation and other tasks?), delete any logged queried domains from the database that are timestamped older than the purge setting length, and if exists, delete any pihole related logs files that contain domain name lookups outside the same period.

Why: Users can have detailed query log information and statistics for a period they choose, with queries they consider no longer useful purged. This would benefit users who don't want the privacy risk of storing lots of data but do want the benefit of short term data. The setting for anonymous query logging does not achieve this scenario.

Suggested range: A number between 1-365 representing how many days data can live for. If left blank or 0, follow existing default behavior instead.

This only relates to DNS lookups (as visible in the 'query log') and is not related to the storage of the blocklists or local devices.

I tried to post in Feature Requests but the button is disabled for the main category and posting directly into one of the sub categories seems wrong.

Why not use MAXDBDAYS?

1 Like

Thanks, I'll use that for the database!

Other than pihole.log's 6 day cycle are there any other locations that store the query log or is that everything? If it's just pihole.log (which is short and can be disabled if needed) and the database (which MAXDBDAYS can do) then this suggestion is no longer needed.

No, that's all, apart from in-memory, of course.

(Note that if you disable pihole.log, it will get harder to find out what domain an ad is coming from, especially since queries are written to the db in certain intervals, not immediately.)

If you want to use a very short MAXDBDAYS (say 3 days) and want the pihole.log retention to match this, you can put in a cron script to delete older logs every night at 0015. This would happen after the nightly log rotation.

1 Like

I was thinking between 7 days to 3 months for the query database depending on how long the data is useful to me, so the pihole.log being around 6 days is perfect as it is - thanks for the tips!