import requests
import browser_cookie3
import json
import datetime
# Log in your site in firefox before running this file
cookies = browser_cookie3.firefox()
def main():
# Base url, path and the instance's cloud id get it from admin.atlassian.net
filename = "automation_logs.csv"
cloud_id = '6934850d-9e66-4a83-948e-123445'
cloud_url = 'https:
file = open(filename, "w")
file.write("execution id, category, start time, rule name, rule id, items\n")
full_url = "<cloud_url>/gateway/api/automation/internal-api/jira/<cloud_id>/pro/rest/GLOBAL/auditlog?limit=50&offset="
full_url = full_url.replace('<cloud_id>', cloud_id).replace('<cloud_url>', cloud_url)
# Change the range upper limit
for iteration in range(0, 200, 50):
print("Executing " + full_url+str(iteration))
response = requests.get(full_url+str(iteration), cookies = cookies)
jsonResponse = json.loads(response.text)
for item in jsonResponse["items"]:
involvedId = ""
for id in item["associatedIds"]:
involvedId = id +";"+involvedId
file.write(str(item["id"]) + "," + item["category"] + "," + str(datetime.datetime.utcfromtimestamp(item["startTime"]/1000.0)) + "," + item["ruleName"]+ "," + str(item["ruleId"]) + "," + str(involvedId) + "\n")
#print(item["id"], item["category"], datetime.datetime.utcfromtimestamp(item["startTime"]/1000.0), item["ruleName"], item["ruleId"], involvedId, sep=',' )
execution_url = "<cloud_url>/gateway/api/automation/internal-api/jira/<cloud_id>/pro/rest/GLOBAL/auditlog/item/"+ str(item["id"])
execution_url = execution_url.replace('<cloud_id>', cloud_id).replace('<cloud_url>', cloud_url)
# uncomment to Optionally get the details of each execution
#response_exec = requests.get(execution_url, cookies = cookies)
#print(response_exec.text)
file.close()
if __name__ == '__main__':
main()
The filter and search for automation audit is improving and still limited. Please allow export the more data fields out so we can do the search or filter in Excel or other format. One use case is an issue is deleted by automation rule but I want to find out which rules did it. So I'd love to be able to search for associated item aka the issue key.