Get value from a list of datadog tags using advanced integration fields
Asked by Bart Scheltinga:

Hi all!

My monitoring tool send a bunch of tags which is encapsulated in the field {{dd_tags}}.

For example it sends:

"Datadog Tags": "Service:Appname, Team:Teamname" (tags found log)

When I use {{dd_tags}} in the advanced integration, it shows all the tags and values beautiful in the alert. But I want to have the value of a certain tag as a field (extra propertie), so I can use it for other things.

For example, add the property "Service" and put "Appname" as a value for that property.

But it can't find a way to do that. {{dd_tags}} works for a field, but when I try other things, like:

{{dd_tags.service}}  
{{dd_tags.SERVICE}}  
{{dd_tags.extract(/service: (\\S+)/) }}  
{{dd_tags.get(0)}}  
{{dd_tags\[0\]}}  
{{dd_tags.substring(5,20)}}

none of this works. What am I doing wrong?

![dd_tags.png](/t5/image/serverpage/image-id/147089i2713CD080954107F/image-size/large?v=v2&px=999 "dd_tags.png")

<https://docs.opsgenie.com/v1.0/docs/datadog-integration>

So I want these tags as separate properties:

![2021-06-11 12_01_33-Datadog Integration.png](https://community.atlassian.com/t5/image/serverpage/image-id/147114iE33FCABF478D45CE/image-size/large?v=v2&px=999 "2021-06-11 12_01_33-Datadog Integration.png")


Answers:
author: Nick H
body: Hi [@Bart Scheltinga](/t5/user/viewprofilepage/user-id/4433099) ,

With the tag you shared above, **Team:MVP** , I believe you can use string processing or regex to extract the MVP value into an extra property:

<https://support.atlassian.com/opsgenie/docs/string-processing-methods-in-opsgenie-integrations/>

<https://support.atlassian.com/opsgenie/docs/regular-expressions-for-improved-alert-filtering/>

You might want to try testing with a few like:

* {{ dd_tags.substringBetween("Team:",",") }}
* {{ _payload.dd_tags.substringBetween("Team:",",") }}
* {{ dd_tags.extract(/Team:(\\S+)/) }}
* {{ _payload.dd_tags.extract(/Team:(\\S+)/) }}

Hope this helps! Let us know if any other these work.

comments: author: Nick H
body: For context as well - I did some testing on a Jira integration (since I do not have a DD instance) - but used some similar tags.

![tagscomm1.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/147743i78EA26D7195319A4/image-size/large?v=v2&px=999 "tagscomm1.jpg")

The issue with using something like {{dd_tags.get(0)}} - will only pull the first tag in the list alphabetically. So there might be inconsistency using the .get since this could change.

For example with 1 and 2 above - those pull the first two labels that are listed in the payload alphabetically:

![tagscomm2.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/147745i69B278B4E0192956/image-size/large?v=v2&px=999 "tagscomm2.jpg")![tagscomm3.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/147744i44F3362BA05064D7/image-size/large?v=v2&px=999 "tagscomm3.jpg")

So string processing and regex might be better options. For example with numbers 3, 4 and 5 in my first screenshot, those pulled these values:

![tagscomm4.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/147748i8F0C25A6752A77F0/image-size/large?v=v2&px=999 "tagscomm4.jpg")

Some of the other examples you shared:

{{dd_tags.service}}  
{{dd_tags.SERVICE}}

\^ I don't believe these would work since the tags are parsed as lists, and these would be used more for arrays.

<br />

{{dd_tags.extract(/service: (\\S+)/) }}

\^ You might be misspelling service, have some case-sensitivity issue, or adding an extra space after service:

Again, hope this helps with troubleshooting! Let us know if you run into any other questions, issues, etc.


author: Bart Scheltinga
body: Thanks so much for you extensive answer [@Nick H](/t5/user/viewprofilepage/user-id/2540930)

I'm not sure why it was not working in the first place, I thought I tried all of the possible options. Maybe Atlassian was having a bad day. or it was the case sensitivity. But the good news is, it is working now! ;-)

{{ dd_tags.substringBetween("Service:",",") }} \<- Did the trick!