TIG Stack - Data Retention Policy

Hello,

I have a Raspberry Pi “server” dedicated to running the TIG stack. There are a total of five Pis feeding data via the telegraf client to the TIG server. I set this all up just to kick the tires and see if I liked it. Well, 18 months later, it’s still going. I’m in the process of rebuilding all of my Pis on the latest release of Raspberry Pi OS. I documented all of the steps I used to set up the TIG server and am confident I can recreate everything. However, when I initially implemented this, I did not set up any database retention policy. Whoops. As a result, my telegraf database is currently 4.6 GB. Fortunately, the Pi is a 4B and still handling things but as you can imagine, it’s quite busy.

When I rebuild the TIG server, I just want to have a simple data retention policy. I don’t need anything sophisticated. For example, retain the real-time data for 30 days. What would be the correct way to enable/implement this?

And a bonus question…is there an “after-the-fact” way to implement a simple data retention policy on the existing database and then purge the old data?

Thank you for any help/guidance.

Hi,

Here is the after-the-fact method: I would see what the current policy name is first, I believe by default it is called autogen:

SHOW RETENTION POLICIES ON "database_name_here"

And then using the policy name on the database as:

ALTER RETENTION POLICY "autogen" ON "database_name_here" DURATION 30d

It should then shortly purge the older data.

1 Like

Thanks, this worked perfectly.