cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create a workflow that gets event details

Duran_Narbona
Participant

I am creating a workflow that gets event details. It's very simple, here is the diagram and this is the code:

Simplified coding:

 

 

 

import { problemsClient } from '@dynatrace-sdk/client-classic-environment-v2';

export default async function ({ execution_id }) {
// get event context
var exec_req = await fetch(`/platform/automation/v0.1/executions/${execution_id}`)
var execution_obj = await exec_req.json()

return execution_obj
}

 

 

 

Advanced coding:

 

 

 

import { problemsClient } from '@dynatrace-sdk/client-classic-environment-v2';

export default async function ({ execution_id }) {
    // get event context
    var exec_req = await fetch(`/platform/automation/v0.1/executions/${execution_id}`)
    var execution_obj = await exec_req.json()

    // get problem
    console.log("Loading Problem details...")
    var event = execution_obj.params.event
    var problem_request = { problemId: event['display_id'] }
    var problem = await problemsClient.getProblem(problem_request)
    console.log(`Problem ${problem.displayId}`)

    return problem
}

 

 

 

As an example, I have looked at an image you have posted on the Dynatrace website, because in the documentation I can't find anything about how to capture these events from a workflow.

My problem is that even though the execution_id of the previous run gets it right, then it tells me that the object is empty --> execution_obj.params

 

Could someone help me with this issue? where is there documentation on this issue and how to process a previous event? Thank you very much

 

Bonus: I tested with this code example, adding the event id by hand, and it works perfectly.

 

 

 

import { problemsClient } from '@dynatrace-sdk/client-classic-environment-v2';

export default async function ({ execution_id }) {
    // get problem
    console.log("Loading Problem details...")
    var problem_id = "-123456789V2"
    var problem_request = {problemId: problem_id}
    var problem = await problemsClient.getProblem(problem_request)
    console.log(`Problem ${problem.displayId}`)

    return problem
}

 

 

 

 

 

 

2 REPLIES 2

Duran_Narbona
Participant

Is working:

var exec_req = await fetch(`/platform/automation/v1/executions/${execution_id}`)

 

the version is v1

 

Duran_Narbona
Participant

Typo: 

var problem_request = { problemId: event['event.id'] }

Featured Posts