# Selectively run Activity Stream on certain projects / templates

**URL:** <https://forum.ansible.com/t/selectively-run-activity-stream-on-certain-projects-templates/31566>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [October 30, 2019, 12:42am UTC](https://forum.ansible.com/t/selectively-run-activity-stream-on-certain-projects-templates/31566 "2019-10-30T00:42:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dien\_N](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@Dien\_N](https://forum.ansible.com/u/Dien_N)\
**Post date:** [October 30, 2019, 12:42am UTC](https://forum.ansible.com/t/selectively-run-activity-stream-on-certain-projects-templates/31566/1 "2019-10-30T00:42:08Z")

</div>

Hi All,

I have a couple of jobs, sourced from one project, that runs often and generates about 200K lines of logs every hours, and growing the postgres database about 100-200GB per month. I also want have the a clean up job that runs weekly but is set to keep the activity streams for 3 months due to business needs.

Does anyone have advice on how to perhaps create a policy for certain jobs (based template ID or project ID) to have a different retention period than the rest? Poking through the code-base i see

1. ActivityStream model exposes timestamp as a string objective

[https://github.com/ansible/awx/blob/devel/awx/main/models/activity\_stream.py](https://github.com/ansible/awx/blob/devel/awx/main/models/activity_stream.py) (90-99)

1. deletion happen here:  
[https://github.com/ansible/awx/blob/devel/awx/main/management/commands/cleanup\_activitystream.py](https://github.com/ansible/awx/blob/devel/awx/main/management/commands/cleanup_activitystream.py)

if asobj.timestamp \>= self.cutoff:  
…  
pks\_to\_delete.add(asobj.pk)

Can we modify the code to do something like this:

if asobj.timestamp \>= self.cutoff:  
…  
pks\_to\_delete.add(asobj.pk)

elsif asobj.timestamp \>= self.new\_cutoff and asobj.job == 13:

…

pks\_to\_delete.add(asobj.pk)

Appreciate the guidance!
