Purging old events

General Discussion

Purging old events

Postby timlegge » Mon Nov 20, 2017 6:22 pm

Hi
Is there any functionality to purge old events? While some mart need the history i dont need more tha a few weeks.

Tim
timlegge
Junior Nut
Junior Nut
 
Posts: 31
Joined: Sat Apr 09, 2016 5:33 pm

Re: Purging old events

Postby kevin » Mon Nov 20, 2017 6:24 pm

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
Not an employee of the company. Just here to help and keep things clean.
kevin
Platinum Nut
Platinum Nut
 
Posts: 994
Joined: Fri Aug 16, 2013 10:10 am

Re: Purging old events

Postby timlegge » Tue Nov 21, 2017 4:30 pm

Thanks. I cleared the events. I may look at some auto purge code at some point
timlegge
Junior Nut
Junior Nut
 
Posts: 31
Joined: Sat Apr 09, 2016 5:33 pm

Re: Purging old events

Postby kevin » Wed Nov 22, 2017 9:53 am

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.
Not an employee of the company. Just here to help and keep things clean.
kevin
Platinum Nut
Platinum Nut
 
Posts: 994
Joined: Fri Aug 16, 2013 10:10 am

Re: Purging old events

Postby trialnerror » Sun Mar 04, 2018 1:06 pm

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.
trialnerror
Junior Nut
Junior Nut
 
Posts: 38
Joined: Wed Jan 03, 2018 11:10 am

Re: Purging old events

Postby kevin » Sun Mar 04, 2018 9:45 pm

Not an employee of the company. Just here to help and keep things clean.
kevin
Platinum Nut
Platinum Nut
 
Posts: 994
Joined: Fri Aug 16, 2013 10:10 am

Re: Purging old events

Postby trialnerror » Mon Mar 05, 2018 4:04 am

Thanks for pointing me in the right direction.
trialnerror
Junior Nut
Junior Nut
 
Posts: 38
Joined: Wed Jan 03, 2018 11:10 am

Re: Purging old events

Postby kevin » Mon Mar 05, 2018 7:44 pm

alternatively you can issue a truncate table event_log within a sqlite utility
Not an employee of the company. Just here to help and keep things clean.
kevin
Platinum Nut
Platinum Nut
 
Posts: 994
Joined: Fri Aug 16, 2013 10:10 am

Re: Purging old events

Postby trialnerror » Tue Mar 06, 2018 4:10 am

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.
trialnerror
Junior Nut
Junior Nut
 
Posts: 38
Joined: Wed Jan 03, 2018 11:10 am

Re: Purging old events

Postby kevin » Wed Mar 07, 2018 8:08 pm

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)
Not an employee of the company. Just here to help and keep things clean.
kevin
Platinum Nut
Platinum Nut
 
Posts: 994
Joined: Fri Aug 16, 2013 10:10 am


Return to General

Who is online

Users browsing this forum: No registered users and 29 guests

cron