Device Log Housekeeping Procedure

I started using Hubitat back in the beginning of May of this year.
I noticed that the hub is keeping event logs of every device since it was installed, close to four months now. Every contact sensor, every temperature change, every motion event, etc....

This all came to my attention when I was looking at the log for my weather device. The log has over 32,000 entries and when I clicked on "Events" from the device page it took about 50 seconds for the log page (listed below) to display. During that time the hub was seemingly locked up. Everything stopped until this gargantuan log came up. Each click through the log takes almost a minute dragging the hub down to a stop.

So the question is; What are the procedures for pruning these logs? Could some of the slowdowns happening be attributed to this?

What version is your Hubitat running?

It should automatically be cleaning up the logs though...

Currently on v2.1.4.128 but I have been through many version upgrades, I assume that logs are maintained by the core operating system but maybe I'm wrong on that account. I checked several devices and the logs go back to the date they were installed.

Just revisiting this, I have some devices with 16,000 pages of device logs.

Can we get some ability to prune event logs?

I resorted to deleting devices and re-creating, but that's time consuming.

Edit: my Sonos devices, have >2000 pages. I have many.

Yes... Hubitat team please look into this. My DB size has grown to 54MB now. Please allow user settable number of events to keep.

@bravenel or @mike.maxwell

Pruning logs?

yes, every day at 2AM if memory serves system event logs are pruned.
Pruning consists of removing all but the most recent 1000 events per device.
An event consists of a distinct name value pair, switch:on and switch:off are two separate event pairs.
We've discussed having an option to change the limits of this, but it's not a high priority at the moment.

@mike.maxwell so the pruning is done only for certain "distinct name value", meaning the string has to match what's being deleted?

it's done for all of them, it figures out what all of them are, then leaves behind 1000.
there is no matching a preset list or anything if that's what you mean
if you have 5000 entries for a custom attribute named "yada" with a value of "putz" on each of 5 different devices, after pruning is complete there will only be the most recent 1000 for each of those 5 devices...

Given the amount of overhead involved in the above, this is one reason I'm not an advocate of creating events for the sake of simply displaying them in the current states of the driver details...

Current states is not an adhoc display area where one can just poke in random data for the sake of visibility.

If the event serves no purpose, meaning there isn't currently, nor will there in any probably ever be an app that subscribes to it, then it shouldn't be an event...

So any reason why I have more than 5000 entries dating back to September 2018?

Same, yesterday I had >16000 pages!!!!!

Edit: I deleted the device and recreated clean, sans event logs, and my DB backup was 0.8 meg smaller.

those aren't distinct events, that's the total count...

ok i'm confuse. Any reason why there are so many of them then? Do they cause the DB to be so big? Can we limit them to something as well?

Yes, we realise, but it's superflous. It records every track ever played on Sonos. 7 speakers around the house. it records the weather in 5 minute increments. I'd love to turn off the ability to record these events, in the device event page.

1 Like

well you didn't show the entire event screen, nor the driver current states, but lets assume that device produces 10 types of events with a possible 5 values each, 10 * 5 * 1000 = 50000, I can't think of any other way of explaining this.

Please post a screen shot of that drivers current state...

But to your point, sure the more events in your system the bigger your database is going to be, that's where they're stored after all, and why I keep telling people not to create worthless events...

Is this what you're looking for? This is the Environmental Sensor using driver "Environment Sensor EX"

I don't really need to know what my Sonos volume was over a year ago.

Yup, that's it.
And honestly of the 15 attributes listed only the last 4 are relevent to automations...
So if you don't want 50k events for that device day after day, then modify the driver, then delete and reinstall the device.

Adding a date, and what date that would be would make that cleanup even more complex.

But cant you just limit the total device logs to 1000 (total, not per attribute + specific 2nd attribute).