how to audit for unused automation rules?
Asked by Phillip C:

So over time automation rules increase and there is no simple way to go through and see when the last time an automation rule was run.

How can i audit our \~400 automation rules to see which ones haven't been run lately?

edit\* Not looking for paid third party addons.


Answers:
author: Darryl Lee
body: Oh hey [@Phillip C](/t5/user/viewprofilepage/user-id/4276845) - so this is not a full solution, but maybe it will help you or somebody else.

[@Hans Polder](/t5/user/viewprofilepage/user-id/5506451) - yeah, there's no published API for Jira Automation Usage, but hey, not having a public API [has never stopped me before](https://community.atlassian.com/t5/Automation-articles/Hacking-Parsing-Automation-Rules-with-JSON-for-Fun-and-Profit/bc-p/2677379#M1626). :-}

So, poking around, I found that you can programmatically get the top 100 used rules for the current month and prior 3 months. Here's endpoints you could use:

https://**${SITENAME}** .atlassian.net/gateway/api/automation/internal-api/jira/**${CLOUDID}**/pro/rest/GLOBAL/highestUsages?limit=100

https://**${SITENAME}** .atlassian.net/gateway/api/automation/internal-api/jira/**${CLOUDID}**/pro/rest/GLOBAL/highestUsages?limit=100\&month=2024-08

(These are the APIs that power the Performance Insights that [@Hans Polder](/t5/user/viewprofilepage/user-id/5506451) referenced.)

I suppose you could combine this data with a listing of all your rules, and then identify rules that don't show up in the top 100 at all, and reasonably conclude that they're not being used.

I wrote a shell script to dump all the rules, generate some CSVs of the rules metadata, create a mapping file for the author IDs to names/emails, and also dump the usage data to a CSV. It requires [curl](https://curl.se/) and one of [my favorite tools:](https://community.atlassian.com/t5/Automation-articles/Hacking-Parsing-Automation-Rules-with-JSON-for-Fun-and-Profit/ba-p/1984033) [**jq**](https://jqlang.github.io/jq/).

<https://bitbucket.org/rudebadmood/workspace/snippets/REz8Mp>

These CSVs can then be attached to a Confluence Page where I used Stiltsoft's excellent [Table Filter, Charts \& Spreadsheets for Confluence](https://marketplace.atlassian.com/apps/27447/table-filter-and-charts-for-confluenc) to Transform that data into a table that you can sort/filter for # of executions, state (disabled or not), author, etc.

![automationscreenshot.png](https://community.atlassian.com/t5/image/serverpage/image-id/347417i4E3C036E715D2713/image-size/large?v=v2&px=999 "automationscreenshot.png")

Oh and the links do take you directly to the rules.

I used the [Table to CSV](https://docs.stiltsoft.com/tfac/cloud/table-from-csv-42246005.html) to convert each of the attached CSVs into tables, and those are nested inside of a [Table Transformer](https://docs.stiltsoft.com/tfac/cloud/table-transformer-42241552.html) using the following SQL query:

```
SELECT FORMATWIKI("[" + CONCAT(T1.'name', "|", "https://SITENAME.atlassian.net/jira/settings/automation#/rule/", T1.'id'),"", "]") as 'Name',
  T1.'description' as 'Description',T3.'executionCount' as 'Executions', T1.'state' as 'State', 
  FORMATDATE(T1.'created') as 'Created', FORMATDATE(T1.'updated') as 'Updated', 
  FORMATWIKI("" + CONCAT(T2.'name', " <", T2.'email', ">"), "") as 'Author' 
FROM T1 
  LEFT JOIN T2 ON T1.'authorAccountId' = T2.'id' 
  LEFT OUTER JOIN T3 on T1.'id' = T3.'id'
```

It's a little... complicated. But yeah, in theory you could plop the shell script on a Mac or Linux host somewhere and have it run every day or week or so, and you'd have a nice sortable/filterable catalog of your rules.

Oh, one last caveat: Cloud Confluence doesn't allow for nesting of macros, so I had to use "Table Toolbox" to put the Table Transformer "inside" of a Table Filter. That looks like this:

![Screenshot 2024-09-14 at 5.57.57?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/347419i3657CA80BC03F6F2/image-size/large?v=v2&px=999 "Screenshot 2024-09-14 at 5.57.57?PM.png")

If Excel or Google Sheets is your jam, there's undoubtably some way to set CSV files as sources and do some kind of similar lookup across the files.

comments: author: Hans Polder
body: Looks very cool [@Darryl Lee](/t5/user/viewprofilepage/user-id/1365322) ! Thanks for responding to my plea for help in our chat.

Hopefully [@Phillip C](/t5/user/viewprofilepage/user-id/4276845) would be able to test this and report back - I'm marking it as action for when I return from my holidays :)


author: Phillip C
body: thanks [@Darryl Lee](/t5/user/viewprofilepage/user-id/1365322) that is indeed an interesting way to go about it! I'll see how i fair attempting this to determine my automation rule usage.

Any questions i'm sure i'll reply back :)


author: Hans Polder
body: [@Phillip C](/t5/user/viewprofilepage/user-id/4276845) ,

What you could do, is go to: https://\<YOUR ENVIRONMENT\>.atlassian.net/jira/settings/automation#/performance-insights.

You can also access this through the regular System Administration section \> Global Automation \> the three dots on the top right \> Performance Insights.

![Screenshot 2024-09-05 065955.png](https://community.atlassian.com/t5/image/serverpage/image-id/345684i9E2BEDFE63FF9A25/image-size/large?v=v2&px=999 "Screenshot 2024-09-05 065955.png")

On this page, you can play around with the toggles to see the data for i.e. the last month. If you sort by execution count, you could identify rules that don't run that often (or maybe too often).

It only shows the top 20 rules though, so you might not get what you want here.

Additionally, you could go to the list of automation rules, simply open them, and review their audit logs. This would help you identify other issues (outside of lack of use) as well. It can be a bit tedious, but it should be doable with \~400 rules.

More information here: <https://support.atlassian.com/cloud-automation/docs/view-your-automation-usage>

comments: author: Hans Polder
body: Hi [@Phillip C](/t5/user/viewprofilepage/user-id/4276845) ,

If this answer helped you, please mark it accepted to help other users find it.


author: Phillip C
body: Hi Hans, no unfortunately this isn't viable for 400+ automations to manually go through each (well i mean sure i could, but heck no i dont want to). The sorting column only seems to bring back results for a small number of automations, so thats not helpful.

The platform falls short of auditing consumption. Surely I'm not the only Atlassian consumer in the world asking this question? Someone has been bound to figure this out already, given how trivial it seems?


author: Hans Polder
body: [@Phillip C](/t5/user/viewprofilepage/user-id/4276845) ,

Thanks for your reply, and I'm sorry to hear that. I agree that it's not that straightforward. Or I might be missing something too, but then at least it's not something obvious. When replying to your initial question, I also checked if any of the Jira Automation REST APIs would be able to do this, but it doesn't appear to be the case.

Additionally, I also tried exporting the rules, but in those JSON results there doesn't really seem to be some information regarding when it was last used.

I just now tried searching [the public backlog for Jira Automation](https://jira.atlassian.com/issues/?jql=project%20%3D%20AUTO%20AND%20issuetype%20%3D%20Suggestion%20AND%20text%20~%20%22last%20used%22%20ORDER%20BY%20created%20DESC) but also there I couldn't really find anything resembling this use case. My last resort/suggestion would be to use the 'Give feedback about Jira' option in the Help-menu in Jira, as below:

![Screenshot 2024-09-12 110940.png](https://community.atlassian.com/t5/image/serverpage/image-id/347011iA1F4805C63738610/image-dimensions/209x251?v=v2 "Screenshot 2024-09-12 110940.png")

Looking forward to hearing any findings you might encounter on this topic!


Tags: cloud

cloud-automation

jira-cloud