25 Jul 2023 07:39 PM - last edited on 26 Jul 2023 04:54 AM by stefan_eggersto
Hi there Dyna fam,
Currently working on a Workflow to is triggered by a Problem event. We want to access the data in that problem and extract a tag (hostname: ABC00001) that is in "entity_tags" in the json payload of the problem event.
Then in the following task, we want to use that extracted tag VALUE (ABC00001) to run the DQL of it logs.
How can we access tag data of the previous task which is the trigger? I see that is possible with {{ }} expressions from this link (Expression reference | Dynatrace Docs) but not sure how to write that expression or where to write in the task we are running a query.
Any advice would be much appreciated.
Solved! Go to Solution.
26 Jul 2023 08:07 AM - edited 26 Jul 2023 08:20 AM
Hi @Kennedy,
Depending on what you're trying to do, there are a few ways to get event data. If you're using the "Run Javascript" action, you can't use expressions for security reasons. Instead, it's really easy to use the Automation utils SDK (check out the docs for examples).
You can use expressions if you're using any other action. You can access event data using the event() expression. And to get results of previous tasks use the result() expression. You can find examples of how to use them in the docs.
Let's say that your first task ("task_1") consumes the event data and returns the results
{ hostname: "ABC00001" }
In the subsequent DQL tasks ("task_2"), you can access these results like this
fetch events | filter hostname == {{ result("task_1").hostname }}
I hope that helps! Let me know if you need any more assistance.