Bug 1428012

Summary: [RFE] Feature to truncate trend tables
Product: Red Hat Satellite Reporter: Paul Armstrong <parmstro>
Component: TrendsAssignee: Ivan Necas <inecas>
Status: CLOSED WONTFIX QA Contact: Katello QA List <katello-qa-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2.8CC: inecas, jcallaha, mhulan, oprazak, sshtein
Target Milestone: UnspecifiedKeywords: FutureFeature
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-09-04 19:05:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Comment 4 Marek Hulan 2017-03-02 07:59:44 UTC
There is a built-in task to clean duplicate entries that's normally run by cron. To run it manually before the upgrade, you can do following

foreman-rake trends:clean

It should lower the number of data. Note that this task was present only before 6.2. There has been a change in how we store trends data so it should consume less data since we do not store duplicate values but intervals (aka diff only). Previous data storage format is automatically converted during the upgrade. Also in 6.2 there's a rake task to reduce points in chart which might help.

foreman-rake trends:reduce

But in general I agree that there should be a clean up mechanism for old data that are no longer relevant and that should probably read the value from "Max trends" setting we have. Shim, is there something I missed? Is there a way to remove old intervals from DB?

Comment 5 Shimon Shtein 2017-03-02 15:04:34 UTC
As Marek said, in 6.2 trends are stored as intervals, which should reduce the number of records significantly. The task that converts old format (point in time) to the new one is the trends:reduce task.

Unfortunately we don't have a task that would clear old intervals from database yet. You can do it manually by running 
"foreman-rake console"
and then:

interval_end = TrendCounter.arel_table[:interval_end]
TrendCounter.where(interval_end.lt(30.days.ago)).delete_all

Before running the deletion procedure, I still recommend running

foreman-rake trends:reduce

And only if it doesn't help, start deleting old records.

Comment 6 Shimon Shtein 2018-03-05 13:07:13 UTC
Created redmine issue http://projects.theforeman.org/issues/22767 from this bug

Comment 7 Bryan Kearney 2018-09-04 18:55:26 UTC
Thank you for your interest in Satellite 6. We have evaluated this request, and we do not expect this to be implemented in the product in the foreseeable future. We are therefore closing this out as WONTFIX. If you have any concerns about this, please feel free to contact Rich Jerrido or Bryan Kearney. Thank you.

Comment 8 Bryan Kearney 2018-09-04 19:05:35 UTC
Thank you for your interest in Satellite 6. We have evaluated this request, and we do not expect this to be implemented in the product in the foreseeable future. We are therefore closing this out as WONTFIX. If you have any concerns about this, please feel free to contact Rich Jerrido or Bryan Kearney. Thank you.