# Custom event alert via code

**URL:** <https://community.dynatrace.com/t/custom-event-alert-via-code/35593>\
**Category:** Open Q&A\
**Tags:** problems-classic\
**Created:** [June 24, 2022, 7:19am UTC](https://community.dynatrace.com/t/custom-event-alert-via-code/35593 "2022-06-24T07:19:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chakrit](https://avatars.discourse-cdn.com/v4/letter/c/96bed5/32.png) [@chakrit](https://community.dynatrace.com/u/chakrit)\
**Post date:** [June 24, 2022, 7:19am UTC](https://community.dynatrace.com/t/custom-event-alert-via-code/35593/1 "2022-06-24T07:19:45Z")

</div>

Dear Dynatrace Team

I would like to Custom event alert via code

Which have requirement :

1. Metric :&nbsp;&nbsp;builtin:service.keyRequest.response.time

2. All request is **key request**

**3.** percentile : 95

4. **But need to exclude only one request** (i cannot move key request from this request because will use this request to dashboard)

Code for custom :

builtin:service.keyRequest.response.time:splitBy(“dt.entity.service\_method”):percentile(95):auto:sort(value(percentile(95),descending))

(Which this code will all service is key request to custom alert)

Question

1. Please provide condition code for move only one request from this custom alert

such as entityName.notequals(~“/api/service/ceee~”)

Thank you.

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [June 24, 2022, 7:28am UTC](https://community.dynatrace.com/t/custom-event-alert-via-code/35593/2 "2022-06-24T07:28:39Z")

</div>

As I understand your question, you need to alert on all key requests response time 95h percentile except a single one. In this case, you need to solve it in a different way and using only include methods.  
For example by using&nbsp;**entityName.in(“name1”,“name2”)** and specifying the requests or by tagging the services by a tag and using that tag in your filter or use the negate criterion as&nbsp;[@mgome](https://community.dynatrace.com/user/8132)&nbsp;advises.

Also - are you really sure you need to have such an alert for all key requests in your environment?

---

<div class="post-metadata">

**Author:** ![chakrit](https://avatars.discourse-cdn.com/v4/letter/c/96bed5/32.png) [@chakrit](https://community.dynatrace.com/u/chakrit)\
**Post date:** [June 24, 2022, 7:37am UTC](https://community.dynatrace.com/t/custom-event-alert-via-code/35593/3 "2022-06-24T07:37:40Z")

</div>

[@Julius\_Loman](https://community.dynatrace.com/user/3364)

Thank you for you reply.

Also - are you really sure you need to have such an alert for all key requests in your environment?  
= Yes

for solution as you provided :  
1. using entityName.in(“name1”,“name2”) and specifying the requests.  
= i have many request to select for custom alert which i think that would be better if can move single request. Have condition code to move only one request?

2. by tagging the services by a tag and using that tag in your filter.  
= Can i use code for move single request use tag ? Please provide condition code.

Thank you.

---

<div class="post-metadata">

**Author:** ![mgome](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@mgome](https://community.dynatrace.com/u/mgome)\
**Post date:** [June 24, 2022, 4:11pm UTC](https://community.dynatrace.com/t/custom-event-alert-via-code/35593/4 "2022-06-24T16:11:40Z")

</div>

Negation is handled by wrapping in “not”.

> **[Environment API v2 - Entity selector](https://docs.dynatrace.com/docs/dynatrace-api/environment-api/entity-v2/entity-selector)**
>
> Learn the Environment API v2 entity selector syntax for filtering monitored entities by type, name, tag, management zone, and health state.

Try wrapping entityName like this:

not(entityName.equals(~“/api/service/ceee~”))
