There are three ways to reduce the number of policy violations stored in Sonatype Lifecycle IQ Server.
1. Delete an Application
Deleting an application will delete all of its associated policy violations
https://help.sonatype.com/en/application-rest-api.html
DELETE /api/v2/applications/{applicationInternalId}
curl -u admin:admin123 -X DELETE 'http://localhost:8070/api/v2/applications/4bb67dcfc86344e3a483832f8c496419'
2. Delete an organization
Deleting an organization will remove all the organizations child applications and organizations.
DELETE /api/v2/organizations/{organizationId}
curl -u admin:admin123 -X DELETE 'http://localhost:8070/api/v2/applications/myOrg’'
3. Run success metrics purger
For each application and stage, the success metrics purger will remove fixed policy violations that are older than the retention policy for the given application and stage
https://help.sonatype.com/en/data-retention.html#cleaning-up-success-metrics-data
curl -u admin:admin123 -X POST http://localhost:8071/tasks/purgeObsoleteSuccessMetrics
(note requires admin access)
Related Requests
Get data retention policies for an organization
GET /api/v2/dataRetentionPolicies/organizations/{organizationId}
curl -u admin:admin123 -X GET 'http://localhost:8070/api/v2/dataRetentionPolicies/organizations/ROOT_ORGANIZATION_ID'
Considerations
- Data retention policies can be changed via the UI or API
https://help.sonatype.com/en/data-retention-policy-rest-api.html - Organizations / Applications can also be deleted through the UI
- Re-evaluating an application after changing its components such that they do not have the policy violations (note that policy violations removed due to this are considered fixed and will then be eligible for removal from the database by the success metrics purger)
- The success metrics purger is automatically ran daily at 1:30 am
- Query to find policy violations older than 1 year
SELECT * FROM insight_brain_ods.policy_violation WHERE open_time < NOW() - INTERVAL '1 year' - Query to find fixed policy violations older than 1 year
SELECT * FROM insight_brain_ods.policy_violation WHERE fix_time < NOW() - INTERVAL '1 year' - If the success metrics purger runs and deletes rows from the policy violations table you should see lines in the log like
“Purged <deletedRows> obsolete records older than <cutoffDate> from violation history of application <applicationName>” - Repository component policy violations are not stored in the same database table as application component policy violations (insight_brain_ods.repository_policy_violations vs. insight_brain_ods.policy_violations )