Page 1 of 1
Purging old events
Posted:
Mon Nov 20, 2017 6:22 pm
by timlegge
Hi
Is there any functionality to purge old events? While some mart need the history i dont need more tha a few weeks.
Tim
Re: Purging old events
Posted:
Mon Nov 20, 2017 6:24 pm
by kevin
If I recall correctly there is a button to clear the event log that should delete from the database, but I don't remember if that was left in or not... check the logging section
Re: Purging old events
Posted:
Tue Nov 21, 2017 4:30 pm
by timlegge
Thanks. I cleared the events. I may look at some auto purge code at some point
Re: Purging old events
Posted:
Wed Nov 22, 2017 9:53 am
by kevin
timlegge wrote:Thanks. I cleared the events. I may look at some auto purge code at some point
Would be fairly trivial, as an example you can look at the code for the automatic configuration backups.
Re: Purging old events
Posted:
Sun Mar 04, 2018 1:06 pm
by trialnerror
So there is no automatic purge setting? If this is to be coded, where are the log files kept? Are they just text on the disk or in a database and, if in a database, how is that accomplished? I haven't been smart enough to link the "clear events" button on the screen to the corresponding section of python code it calls. Pointing me to a module/function would be a big help if you can. After running for about a month I've got over 27,000 entries - mostly hardwired motion sensors. Thanks.
Re: Purging old events
Posted:
Sun Mar 04, 2018 9:45 pm
by kevin
Re: Purging old events
Posted:
Mon Mar 05, 2018 4:04 am
by trialnerror
Thanks for pointing me in the right direction.
Re: Purging old events
Posted:
Mon Mar 05, 2018 7:44 pm
by kevin
alternatively you can issue a truncate table event_log within a sqlite utility
Re: Purging old events
Posted:
Tue Mar 06, 2018 4:10 am
by trialnerror
More unknown realms to explore. Thanks for the guidance. Is there a data dictionary for the table, or can you tell me the name of the time stamp field in it? I think I'd rather just delete records older than X days.
Re: Purging old events
Posted:
Wed Mar 07, 2018 8:08 pm
by kevin
Here is the event_log table definition
- Code: Select all
id = Column(db.Integer, primary_key=True)
type = Column(db.SmallInteger, nullable=False)
timestamp = Column(db.TIMESTAMP, server_default=db.func.current_timestamp(), index=True)
message = Column(db.Text, nullable=False)