25 Jun 2024 08:34 AM
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
Solved! Go to Solution.
27 Jun 2024 11:42 AM - edited 27 Jun 2024 11:42 AM
Hi @amita,
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 yet? It includes an example of ingesting events.
Kind regards,
Sarah
28 Jun 2024 10:06 AM
Hi @amita ,
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: https://developer.dynatrace.com/preview/reference/sdks/#error-handling
02 Jul 2024 07:36 AM
Hi @amita - I hope the above answers were help you to solve your issue, if so, please 'accept as solution', to help us close this community question.
Thanks, Penny
03 Jul 2024 08:43 AM
Thanks for the suggestions .Will try and get back to you incase of any query.
Amita