Hi there,
I have emails coming in to Opsgenie to create alerts and they contain the JSM issue key.
Is there a clever way that I can pull that email out and then link the issue back to JSM?
I know it can be done via the JSM integration, just hoping I can use a value in the email and link it that way also?
Thanks
Hi @Ste404 ,
You can use the dynamic field where the JSM issue key is stored at the end of a hard-coded URL. If the alert was coming directly from JSM, it would be stored in the 'key' dynamic field. So you use this format to create a link:
https://JIRA-URL/browse/{{key}}
If it's coming from an email, you would need to have the JSM key be the only value in that field (and then plug that value in where 'key' is in the above) otherwise you would need to parse the JSM key out using string processing and regex:
https://support.atlassian.com/opsgenie/docs/string-processing-methods-in-opsgenie-integrations/
https://support.atlassian.com/opsgenie/docs/regular-expressions-for-improved-alert-filtering/
The email is actually being sent from JSM from an automation. It is set up this way due to a true or false being set in Assets to trigger the email to Opsgenie.
Basically I can put the {{issue.key}} anywhere in the outbound email.
Where can I populate the dynamic field assuming the key is coming in as a value from JSM?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ste404 You can put the {{issue.key}} anywhere in the email, then you would just need to parse it out. For example, if you added the issue key to the email subject, then in the email integration in Opsgenie you would use the {{subject}} dynamic field along with string processing to create the link.
You would need to have some way to parse it out based on some recurring unchanging pattern of where the key occurs in the subject and what text it is surrounded by.
That is what the string processing and regex can help with. In the example below we are assuming that the issue key in the email subject comes after the string 'Key:' and that there is a space after it.
https://JIRA-URL/browse/{{ subject.extract(/Key: (\S+)/) }}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the info, I will have a muck around with this and see what I can come up with.
Stay tuned :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ok that works easy enough and there is a URL back to the issue in JSM.
BUT, is there a way to force it to populate that in the 'Jira Service Management requests' section.
I know I can manually click Link request, but is there a way that it could be inserted as part of the incoming email so when you go into the issue, comment, acknowledge etc, there is a link to JSM formed?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For the 'Jira Service Management requests' section to be automatically populated, the alert has to be created by JSM.
For alerts not created by JSM, the only way to add a link to a JSM ticket in that section is by manually selecting it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yep all good, I assumed as much. There is a link in place now and literally seconds worth of work using that number to link the request.
One last thing, is the jira url something that can be extracted.
I know the value is intertwined into what is coming in but not sure where the best place to parse it and then add it to the //URL/browse... side of things.
It is there in the 'from_address, and I was trying to put that in here
https://from_address.extract(/@.........../browse/{{ subject.extract(/Key: (\S+)/) }}
the ......... represents where this just goes sideways :D
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Figured it out
https://{{from_address.extract(/@(\S+)/)[1]}}/browse/{{ subject.extract(/Key: (\S+)/) }}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.