# Davis Forcast Issue in raising violation event

**URL:** <https://community.dynatrace.com/t/davis-forcast-issue-in-raising-violation-event/46290>\
**Category:** Developer Q&A Forum\
**Tags:** dql, workflows\
**Created:** [June 25, 2024, 7:34am UTC](https://community.dynatrace.com/t/davis-forcast-issue-in-raising-violation-event/46290 "2024-06-25T07:34:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![amita](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@amita](https://community.dynatrace.com/u/amita)\
**Post date:** [June 25, 2024, 7:34am UTC](https://community.dynatrace.com/t/davis-forcast-issue-in-raising-violation-event/46290/1 "2024-06-25T07:34:54Z")

</div>

We are trying to raise violation event using Davis Forecaster in Workflow.

However getting below error for violation task " **An error of type UNCAUGHT\_EXCEPTION occurred in an imported library: 400: Constraints violated.**  
**at EventsClient.createEvent (file:///opt/sdk\_modules/@dynatrace-sdk/client-classic-environment-v2/esm/index.js:9655:17)**  
**at eventLoopTick (ext:core/01\_core.js:169:"**

Below is the “violation event” task code

import { eventsClient, EventIngestEventType } from “@dynatrace-sdk/client-classic-environment-v2”;  
import { execution } from ‘@dynatrace-sdk/automation-utils’;

export default async function ({ execution\_id }) {  
const exe = await execution(execution\_id);  
const checkResult = await exe.result(‘check\_prediction’);  
const violations = await checkResult.violations;  
// Raise an event for each violation  
violations.forEach(function (violation) {  
eventsClient.createEvent({  
body : {  
eventType: EventIngestEventType.ResourceContentionEvent,  
title: ‘Custom Dummy Problem for Demo(kindlyignore)’,  
entitySelector: ‘type(MEMORY),entityId("’ + violation[‘dt.runtime.jvm.memory.free’] + ‘")’,  
properties: {  
‘dt.entity.process\_group\_instance’ : violation[‘dt.entity.process\_group\_instance’]  
}  
}  
});  
});  
};

The DQL is timeseries exhausted\_memory=avg(dt.runtime.jvm.memory.free) , by: { dt.entity.process\_group\_instance } , filter: { dt.entity.process\_group\_instance==“PROCESS\_GROUP\_INSTANCE-ID”}

Let us know if something is missing or need to change here

Thanks in Advance

Regards

Amita

---

<div class="post-metadata">

**Author:** ![SarahFaustmann](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@SarahFaustmann](https://community.dynatrace.com/u/SarahFaustmann)\
**Post date:** [June 27, 2024, 10:42am UTC](https://community.dynatrace.com/t/davis-forcast-issue-in-raising-violation-event/46290/2 "2024-06-27T10:42:14Z")

</div>

Hi&nbsp;[@amita](https://community.dynatrace.com/user/63691),

It’s possible that the body has misconfigured information, which would result in a 400 range error (bad request). You could try an API development tool such as Insomnia or Postman to ensure that communication to the endpoint is working as expected. Have you checked out the [guide for ingesting Davis events](https://developer.dynatrace.com/develop/data/ingest-data/#events-davis-events) yet? It includes an example of ingesting events.

Kind regards,  
Sarah

---

<div class="post-metadata">

**Author:** ![Roberto\_Tonino](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/roberto_tonino/32/41817_2.png) [@Roberto\_Tonino](https://community.dynatrace.com/u/Roberto_Tonino)\
**Post date:** [June 28, 2024, 9:06am UTC](https://community.dynatrace.com/t/davis-forcast-issue-in-raising-violation-event/46290/3 "2024-06-28T09:06:19Z")

</div>

Hi&nbsp;[@amita](https://community.dynatrace.com/user/63691)&nbsp;,

to get more information, can you try to wrap the “eventsClient.createEvent” code in a try/catch block? You can find more information and examples in the docs:&nbsp;[SDK for TypeScript | Dynatrace Developer](https://developer.dynatrace.com/preview/reference/sdks/#error-handling)

---

<div class="post-metadata">

**Author:** ![PennyScully](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pennyscully/32/32029_2.png) [@PennyScully](https://community.dynatrace.com/u/PennyScully)\
**Post date:** [July 2, 2024, 6:36am UTC](https://community.dynatrace.com/t/davis-forcast-issue-in-raising-violation-event/46290/4 "2024-07-02T06:36:53Z")

</div>

Hi&nbsp;[@amita](https://community.dynatrace.com/user/63691)&nbsp;- I hope the above answers were help you to solve your issue, if so,&nbsp;please ‘accept as solution’, to help us close this community question.&nbsp;  
Thanks, Penny

---

<div class="post-metadata">

**Author:** ![amita](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@amita](https://community.dynatrace.com/u/amita)\
**Post date:** [July 3, 2024, 7:43am UTC](https://community.dynatrace.com/t/davis-forcast-issue-in-raising-violation-event/46290/5 "2024-07-03T07:43:46Z")

</div>

Thanks for the suggestions .Will try and get back to you incase of any query.

Amita
