Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to use the "contains" filter on a policy to match alerts on tags?

Hi,

 

I'm trying to define a new "delay" policy that would delay until the next morning my alerts that have a tag that contains the "test" string.

I created the policy as shown in the picture below:Screenshot from 2021-02-16 19-34-25.png

I'm using Lamp to test my alerts:

  • If I send an alert with:
    opsgenie-lamp createAlert --message "hello world" --tags "test"
    Then the filter matches, and my alert is correctly delayed.
  • If I send an alert with:
    opsgenie-lamp createAlert --message "test jon" --tags "test 123"
    Then the filter doesn't match, the alert is not delayed and I'm paged instantly. I tried various combination of the tag value: "test123", "test-123", "test 123", the filter doesn't match.

I could use a regex for that, but I wanted to be sure I understood "contains" correctly (does it actually mean "equal"?)

Thanks for your help!

1 answer

1 accepted

2 votes
Answer accepted
Nick H Atlassian Team Feb 16, 2021

Hi @Jonathan Ballet ,

When filtering by tags and/or teams, please use the 'contains' operator and enter the full tag/team name. These two attributes are list attributes and the 'contains' operator would search for the specific tag/team typed within the list: https://docs.opsgenie.com/docs/terminology-and-capabilities-of-the-reporting-page#advanced-capabilities

^ Although the doc outlines this in reporting, the same goes for filtering tags in policies, integrations, etc. 

Regex can also be used like you mentioned as well! Hope this helps. Let us know if you have any other questions around this.

Hi @Nick H

Thanks for your answer! If I understand correctly, "contains" is for when there's a list of values, such as a list of tags, and the filter would lookup one of the value of the list, right?

It possible to combine both behaviors? Ideally, Id' like to filter my alerts if any of the tags value matches the regexp ".*test.*", would that work?

Nick H Atlassian Team Feb 16, 2021

That's correct. Tags will always be in a list since they are parsed as an array in the payload. Regex can act like the "contains" condition using an expression like yours.

For example with the test below (no pun intended) - I have a policy that filters using regex, and applies to alerts that match .*(test).* in the tag.

I even added "test" in the middle of the tag to show how it can act like "contains" in this example: thisisatestforjb

regextagcomm1.jpgregextagcomm2.jpg

@Nick H Thanks a lot, I'll try with this type of filters then!

Like Nick H likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Opsgenie

Leveraging Atlassian’s Opsgenie and AWS Cloudformation Registry to stay ahead of incidents

In the past, managing IT infrastructure was a hard job. It required a lot of manual effort and it was hard to keep track of all the necessary information (monitoring, scalability etc). Thankfully, as...

1,756 views 0 10
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you