Avoid a duplicate ticket with Datadog and Jira integration
Asked by Anthony Morais:

In my environment I have an integration of Datadog and JSM, that is, when there is an alert, a ticket is created automatically.  
I would like to know if there is a way to create an automation that, if there is already an open ticket, do not open another one.


Answers:
author: bmccoy
body: Hi!

I'm not sure how the current integration is set up, but it can be a bit tricky to **prevent**tickets from being created unless it is automation that is creating them. However, you should be able to set up an automation that will close an issue as a duplicate.

* Listen to issue created events,
* Filtering the automation down to just those that come from datadog (e.g. via issue type or labels).
* Check if there are any other issues that have the same description/summary/custom fields (or however you plan to identify the duplicates)
* If yes, close the ticket.

It might look something like this:

![Automation - Code Barrel JIRA 2022-08-30 09-05-44.png](https://community.atlassian.com/t5/image/serverpage/image-id/213386i7FAAA27421AF021D/image-size/large?v=v2&px=999 "Automation - Code Barrel JIRA 2022-08-30 09-05-44.png")

Cheers,  
Brydie

comments: author: Anthony Morais
body: Isso n?o seria o ideal para mim, mas ajudaria se voc? adicionasse na automa??o, depois de Conclu?do, incluir um coment?rio de que o ticket criado anteriormente (se estiver no status Aberto) j? est? sendo tratado. Seria algo assim:

This ticket is already being handled in ticket {{issue.key}}  

<br />


author: Marlon Bacala
body: Hi. Can you guys tell me where do I set this app.


author: Diana_Architect_ZigiWave
body: [@Marlon Bacala](/t5/user/viewprofilepage/user-id/5237845) which app? Jira Automation?


author: Marlon Bacala
body: [@Diana_Architect_ZigiWave](/t5/user/viewprofilepage/user-id/4803013) it is this <https://www.atlassian.com/devops/observability-tutorials/jira-datadog-integration>.   

I integrated datadog with Jira. It seems to be working since I followed this document <https://www.atlassian.com/devops/observability-tutorials/jira-datadog-integration>. However I got stuck in section 2 (Automatically create issues from Datadog alerts). Ticket is automatically created once alert is triggered however it creates a duplicate ticket when alert is re triggered. Can anyone help thanks.


author: Gabriel Furstenheim
body: In case anybody stumbles into this problem again, the expression is in the right path, but it is far from correct.

Something like this is more correct (but still not perfect):

\`\`\`

status NOT in ('Done') AND key != {{triggerIssue.key}} AND summary \~ '{{triggerIssue.summary.replaceAll("\\\\\]", "\\\\\\\\\\\\\\\\\]").replaceAll("\\\\\[", "\\\\\\\\\\\\\\\\\[")}}'

\`\`\`

You need to avoid checking the issue against itself or against closed tickets. But then, you also need to escape the characters in the summary. In particular \`\[\`which is a parameter in datadog


author: Diana_Architect_ZigiWave
body: [@Anthony Morais](/t5/user/viewprofilepage/user-id/5000156) hi! Hope you've found the reason behind the duplication issue. May I ask if you're using any additional tools to establish the integration? Perhaps the problem comes from it? I'd go back and see if the mappings are set properly. If, at some point in the future you happen to have a similar project and you're open to using a 3rd party solution - check out [ZigiOps](https://marketplace.atlassian.com/apps/1227566/zigiops-integrate-jira-with-datadog?hosting=cloud&tab=overview). It can help you connect the two systems and sync their data. It had advanced mapping settings so it would not allow any duplication. Feel free to look at it and if you decide you'd like to know more about it work - you can [secure a demo meeting.](https://bit.ly/3pXlpg3)


Tags: integration