How to bulk recalculate missing SLAs
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Purpose
In some rare cases, due to corruption or unexpected events, SLA values can become missing on Jira issues: for example, this screenshot illustrates missing SLA values for "Time to resolution" SLA:
There is a KB article that describes how to fix corrupted / missing SLA information. However, sometimes, the count of affected issues can be huge, and it can be cumbersome to extract all relevant issue keys when building the reconstruction REST call.
This article aims to provide a simpler solution that will do the following in one go:
- Identify relevant issues with missing SLAs and
- Send a REST POST request with all identified issue keys included.
Solution
Jira Service Management 4.9.0 and lower
If possible, try this procedure on a test environment first. Also, make sure to take a database backup before proceeding.
Let's assume that the SLA is called "Time to resolution" and that the project key is TEST:
First, create the filter named "TimeToResolutionExists", that will filter all issues that do not have either completed or non-completed SLA information present (which is technically an SLA with missing value and that is not expected):
"Time to resolution" = completed() OR "Time to resolution" != completed()
- Enable sd.sla.fix.timeline dark feature, as per Missing or corrupted SLA data in Jira Service Management article
To automatically pull relevant issues and trigger a POST REST call for SLA reconstruction, the following terminal command can be executed:
curl \ -u username:password \ -X POST \ -H "Content-Type: application/json" \ --data '{"jql":"project = \"Project_Name\" AND NOT filter = \"TimeToResolutionExists\"","fields":["key"]}' \ "https://my.example.servicedesk/rest/api/2/search" \ | jq '[.issues[].key]' \ | curl \ -u username:password \ -X POST \ -H 'Content-Type: application/json' \ 'https://my.example.servicedesk/rest/servicedesk/1/servicedesk/sla/admin/task/destructive/reconstruct?force=false' \ -d @-
- Make sure you have jq package installed and available on the machine where you are running the command.
Replace username and password with the admin username and password
- Replace my.example.servicedesk with your Jira base URL
- Replace Project_Name with the actual name of the project where the SLAs are missing. Limiting the REST call to one project will help avoiding global reconstruction and potential performance issues.
- A successful call will result in a JSON content that represents description of SLA values, as they stored in the database.
- Viewing the affected issues in Jira will now show proper SLA values:
Jira Service Management 4.9.1+
In JSM 4.9.1, new REST endpoints for SLA recalculation have been introduced. Specifically, REST endpoint /rest/servicedesk/1/servicedesk/sla/admin/task/destructive/reconstruct/jql enables the admin to pass a JQL clause / filter so that all issues covered by the JQL will have their SLAs recalculated. Please see Missing or corrupted SLA data in Jira Service Management for more information.