Is there a way to customize the Alert Filter for the gitlab integration
Asked by Alberto Ruis:

My use case is that I want to create an alert if a job event has failed.   
I do realize that the current functionality for Job Event isn't listed  
<https://docs.opsgenie.com/docs/gitlab-integration>

But in the Advanced setting in the integration I'm able to create alert policy when the Object Kind is equal to build, likely due to the fact both merge request and job events have the key object_kind in the payload  
<https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#job-events>  
<https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#merge-request-events>

I do also have the ability to get at items in the payload via the dynamic fields feature i.e. {{_payload.build_status }} <https://docs.opsgenie.com/docs/draggable-fields#using-raw-parameters-from-webhook-url-payload-and-headers>

<br />

While I can get access to the items in the payload in the Value field in an alert filter,  
I can't set in the initial field we're looking at initially, see the screenshot on what I mean.

![Opsgenie_-_Integration.png](https://community.atlassian.com/t5/image/serverpage/image-id/97789i79DB5EEEE4A4BD9F/image-size/large?v=v2&px=999 "Opsgenie_-_Integration.png")

<br />

There's the API integration, <https://docs.opsgenie.com/docs/api-integration>, but it doesn't support dynamic fields from the payload, I do see an Extra Properties fields that I could set but it doesn't integrate easily as the current gitlab integration i.e. formatting the request and authorization.

<br />

Thoughts?


Answers:
author: Chris DeGidio
body: Hi Alberto,

I hope this answer finds you well and you are having a great day.

To start off I will go ahead and submit a feature request to our engineering team for the functionality of adding that field as a draggable field to the GitLab integration so that you can then use the filtering within the create action.

As a work-around though I could suggest that you utilize global policies/team routing rules depending upon how you have the integration current configured. For example, if this is a global integration you could set up that status to be pulled into the extra properties section of the alert and then you will be able to apply a filter condition based on that key-value pair via global policies, team policies, and team routing rules.

For example in this first screenshot I setup the global policy to match for the failed build and assign a team to that alert. This would be possible with the integration being global (not assigned to a specific team)

In the second screenshot, I am showing you how you could handle this on the alert routing rule portion if the integration is assigned to a team. Whenever the integration is assigned to a team and an alert is created via that integration the team's routing rules will be assessed. What this will do is essentially route the alert to nobody if the key value of build status failed is not in the alert. You could then set up a team notification policy to auto close those alerts that hit the team but are not routed anywhere. The final screenshot is what that would look like under the team that owns the integration.

Please let me know if there are any further questions. Thanks so much

comments: author: Chris DeGidio
body: This is a followup reply since it seems the screenshots I had created for you did not show. ![Opsgenie_-_Apache-ops1.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/98153i4084E9A60585FA2C/image-size/large?v=v2&px=999 "Opsgenie_-_Apache-ops1.jpg")![Opsgenie_-_Apache-ops12.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/98154iB393FB4239269F63/image-size/large?v=v2&px=999 "Opsgenie_-_Apache-ops12.jpg")![Opsgenie_-_Policies.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/98155iD3873964747A6613/image-size/large?v=v2&px=999 "Opsgenie_-_Policies.jpg")


author: Pete Sam
body: hi, have you ever heard back from your engineering team regarding the feature request?   
I dont get how you add global policies/team routing rules. I dont seem to have the permission to setup such things, as I can only see my team in the teams view. or is there a way to add custom draggable fields (attributes)? or only as admin?

what is a "global integration"? I could use API integration but this wont work with Gitlab as the auth-token cannot be send via GET request in API v2 of Opsgenie... and I guess the fields wont macht.

why dont you just expose "object_attributes" (with a custom textfield for subfields or something) like you already do for "object_kind" "Filter\> Match conditions". then your team does not have to add attributes and users can use ANY attribute?

```
{ 
  "object_kind": "pipeline", 
  "object_attributes":
    { 
      "id": 31, 
      "ref": "master", 
      "status": "success",
[...]
```

just need to check the status of a pipeline...

aka {{_payload.object_attributes.status}} as Filter

greetz and thx


author: camila.naranjo
body: Do you found any way to do it? I have the same problem


author: Stefan Kleff
body: Same here :/

And the solution is super quick to implement.


author: Emiliano Fernando Cicarelli
body: hi, have you ever heard back from your engineering team regarding the feature request?   

tks,

Emiliano


Tags: cloud

gitlab