Exclude devices/variables from logging

Posted on
Wed Mar 10, 2021 1:58 am
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Exclude devices/variables from logging

Hi!

My PostgreSQL-db is getting toooo big, for regular backups even w/ Auto prune @ 2 years (I would like to use Never but that is not doable).
I have 700+ tables in my indigo_history db and I think I use about 50-100 of them. Is it possible to exlude the devices/variables I don't need (or exclude all and include only the ones I need)?

Best regards, L

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Posted on
Wed Mar 10, 2021 8:19 am
siclark offline
Posts: 1961
Joined: Jun 13, 2017
Location: UK

Re: Exclude devices/variables from logging

Not in the sql logger I don’t think but if you move to the Grafana plugin you get to choose which devices you store in influxdb. That might work for you?

Posted on
Wed Mar 10, 2021 8:45 am
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Re: Exclude devices/variables from logging

Thanx.
Ok, to bad.
Can't switch db now after many years of postgres, would be far to much work on the frontend part...
Might construct my own db logger by triggers on the devices I need but I don't know if that is going to be a mess.

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Posted on
Wed Mar 10, 2021 8:49 am
siclark offline
Posts: 1961
Joined: Jun 13, 2017
Location: UK

Re: Exclude devices/variables from logging

You obviously use your postgres db more than me. I thought the same, but realised I got more value on having it in Grafana even if I lost some history.

However, a quick search found this... http://mfadhel.com/transferring_data_to_influx/. you might be able to migrate the data you want over?

Simon

Posted on
Wed Mar 10, 2021 10:34 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Exclude devices/variables from logging

You could write a script or something that runs once a day and just deletes the extraneous data.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Mar 10, 2021 3:46 pm
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Re: Exclude devices/variables from logging

That is actually a great idea. And make a whitelist of devices I would like to keep data for.

Thanks!

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Posted on
Wed Mar 10, 2021 3:54 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Exclude devices/variables from logging

Take a look at the release notes for Indigo 7.4.1 and search on sqlLoggerIgnoreStates. You can use the Global Property Manager plugin (linked in the release notes) to add a new property to the devices you want skipped. If you add sqlLoggerIgnoreStates with a value of * then Indigo won't write new rows to the table for that device. Might be a pain if you have to do it for a lot of devices, but you should only need to do it once.

Image

Posted on
Thu Mar 11, 2021 1:41 am
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Re: Exclude devices/variables from logging

Interresting, but it will not delete the table for that device I guess? Can I drop that table or is it going to be recreated but not populated w/ values?

//L

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Posted on
Thu Mar 11, 2021 10:01 am
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Exclude devices/variables from logging

You should be able to drop it. I believe it won't be re-created (but there is a possibility it will be but either be empty or just have a single row).

Image

Posted on
Fri Mar 12, 2021 4:46 am
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Re: Exclude devices/variables from logging

Thanks.

Does the SQL logger do "VACUUM FULL" on the tables?
And when do they prune old data? I have set variables to 1 week auto prune (from 2 years) but I don't see that the tables use less space and they do still have data for 2 years.

//L

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Posted on
Fri Mar 12, 2021 4:31 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Exclude devices/variables from logging

The pruning happens on the tables after new items are inserted on tables (so when device states or variable values change).

Indigo doesn't do a VACUUM FULL on the table, but probably should at least on every server restart. We should also perform the pruning when the plugin first starts up. I'll add both to my feature request / todo list.

Have you tried manually running the VACUUM FULL on the database file? Make sure you stop the SQL Logger Plugin before you do so, but I'm curious if that works for you and shrinks the file.

Image

Posted on
Sat Mar 13, 2021 9:46 am
RogueProeliator offline
User avatar
Posts: 2501
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: Exclude devices/variables from logging

Indigo doesn't do a VACUUM FULL on the table, but probably should at least on every server restart. We should also perform the pruning when the plugin first starts up. I'll add both to my feature request / todo list.

Just a warning, that puts the table into an exclusive lock state and could be problematic if plugins are updating all their states/devices at startup.

It might be more than you want to take on, but I had started to modify the SQL Logger at one point to utilize a queue system where the updates were stuck in a queue which was being pulled/executed on a separate thread. This allowed batching up of commands while performing something that locked a table. Was also looking into a faster way to add columns to the table based on some postgre team recommendations, but then Weather Underground went and quit and made that all a moot point in my case (as that was my offending table).

Adam

Posted on
Sun Mar 14, 2021 3:37 pm
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Re: Exclude devices/variables from logging

I did a VACUUM(FULL, ANALYZE, VERBOSE) on db indigo_history (700+ tables), took about 10 minutes and did trim away 2 GB of 9+GB total.
I kept the SQL-plugin running and no errors in log, my frontend webpage worked during the process aswell (the pages I tested) so I guess the exclusive lock is only for the table that is vacuumed for the moment and not all tables at ones.

//L

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Posted on
Mon Mar 15, 2021 8:26 am
RogueProeliator offline
User avatar
Posts: 2501
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: Exclude devices/variables from logging

so I guess the exclusive lock is only for the table that is vacuumed for the moment and not all tables at ones.

Correct, tables are only going to lock one at a time unless you put the database in single-user mode.... and commands can wait a set amount of time, if the operation occurs quickly then it isn't an issue. My mentioning of it was more in the fact that on startup there seems like there is a high likelihood of things attempting to insert into the very table that is being locked.

I've seen errors with this in Indigo not in vacuuming but when a state definition change causes the table to be modified. When Dave would add states to Weather Underground, for instance, I would get a TON of errors while the plugin attempted to add (or modify if a data type change) the column. Large table and had tons of rows, though.

Might be over thinking it in this case, but performance of the database from applications is a big portion of my job so I tend to worry about those things outside of it as well. I guess my point is it could be prevented fairly easily to be sure it doesn't occur.

Posted on
Mon Mar 15, 2021 12:43 pm
DrLove offline
Posts: 260
Joined: Dec 12, 2014
Location: Sweden

Re: Exclude devices/variables from logging

I believe one should minimize errors and maximize performance to, both at work and at home so I appreciate every input I can get!

Now I have to decide if I should make a whitelist of devices I want to keep forever(auto prune = forever) an prune the rest to about 6 months via a script OR copy data periodically from these devices to new tables that Indigo does not prune and set auto prune to 6 month :roll:
The latter might be better if I install a new device (different ID) that replace the old one, then I can map the new device to my custom table.

//L

Love Kull (yes it's my name)
Blog (in Swedish)
Sweden

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests