This workaround is intended to people that would like to set up an “Alert Notification” whenever a specific issue queue has reached a certain threshold. We will make use of Automation For Jira, JQL, Rest API and Web Requests to accomplish this. I will explain the needed steps below:
Initially you will need an API Token created for authentication, to send a web request to an API endpoint using your automation rule. In case you don't have any API token configured, you may check the needed steps at this document.
Once created you won't be able to see it again, so I'd advise copying the API token string to another location, we will need this later.
With the above token created, you will need to encode it to the authorization string. At the 2nd step from this community post there's a detailed step on how to do so, but basically we can make this through any online tool like Base64 encode or you can use a terminal session and execute the following:
$ echo -n "<email@example.com>:<YOUR_TOKEN_HERE>" | base64
Where you would need to replace <email@example.com> by your user’s email address and <YOUR_TOKEN_HERE> for the API token you generated at the previous step, separated by the “:” character and between the ““ characters. Once you execute this command, please save the generated string to use later.
Go to your Project Settings > Automation and start a new rule in the following components:
In this example I will use the "Issue created" trigger.
The 2nd component should be a “JQL Condition” component, where you will use the same JQL set in your issue queue from your JSM project. This component is set to avoid sending the notification for every ticket that is not from the same queue that you need to alert. In this example, I’ve used the JQL from the “All Open” queue from my test project.
The 3d component should be the “Send web request” action component. Here it gets a bit tricky, you will have to configure it with the following values:
Web request URL:
{{baseUrl}}/rest/api/2/search?jql=<YOUR-QUEUE-JQL>&maxResults=0
The above is your instance's API endpoint to return the number of issues based on a determined JQL. You may find additional details for this API in this link.
Remember to replace <YOUR-QUEUE-JQL> for your queue JQL in the needed format. For my example queue, the syntax will be like this:
{{baseUrl}}/rest/api/2/search?jql=project=TISM+AND+resolution=Unresolved&maxResults=0
Headers:
Accept: application/json
Authorization: Basic <base64-token>
Remember to replace <base64-token> by your generated base64 encoded string at the 1st step from this post.
HTTP Method:
GET
Web request body:
Empty
And Check the "Delay execution of subsequent rule actions until we've received a response for this web request" checkbox.
For the 4th component we will compare the number of returned tickets, using the “Advanced compare condition” component, to check if the number of issues returned from the web request is greater than a specific number. We will use the following values:
First value:
{{webResponse.body.total}}
Condition:
greater than
Second value:
25
This means that I would like the alert to be triggered once the queue has reached at least 25 issues.
Finally, for the last component we will use the “Send email” action component to send an email alert to the needed recipients. In my example I will notify the users from the “administrators” group and the “email@domain.com” email address. You may also customize your email notification subject and content.
After setting up your automation rule, you should have something similar to this:
Rodrigo Henrique
5 comments