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

DQL, Workflows and Event triggers. Error in arguments passed

IKnowNothing
Visitor

Hello!
I've been at this way too long, and can't find any solution in sight, no matter what I do.

You can see the issue in the image, but anytime I resort to use any field, Workflows and DQL refuse to work with it.

I can't find the way to escape it. In one case, I had to use the response of a workflow, encase it in '"', and pass it on to the next process.

Also, I tested and manually inserted the correct loginkey in the query, surrounded by "", and there was a result.

 

fetch bizevents, from:now()-20m
| filter LoginKey == "h3a8y937coVqgChe"
| fields Username, Country, UserId

 

 

I'm using the following to capture the value I want:

 

 

fetch bizevents, from:now()-20m
    | filter LoginKey == {{event()['LoginKey']}}
    | fields Username, Country, UserId

 

 

This is the same:

 

 

fetch bizevents, from:now()-1h
    | filter LoginKey == {{event('LoginKey')}}
    | fields Username, Country, UserId

 

 

 

This is a serious impediment, as I need to make queries in regards to specific event information.

I really need help, guys...

 

I can work with Javascript, but I can't find the wait ti get the event trigger information.

EDIT:
Like this works:

  var c = await ex.event();
2 REPLIES 2

Hi @IKnowNothing 

The syntax you used in DQL {{event('LoginKey')}} is Jinja - it's a templating engine. You can't use it in DQL, but you can use it in JavaScript. The usage is described in the documentation: https://docs.dynatrace.com/docs/platform-modules/automations/workflows/reference.

However, as you noted, it can be done without using Jinja. In your case, you can use the result in a DQL query called via Javascript:

 

import { queryExecutionClient } from '@dynatrace-sdk/client-query';
import { execution } from '@dynatrace-sdk/automation-utils';
 
export default async function ({execution_id}) {
 const timeout = 60;
 const ex = await execution(execution_id);
 const c = await ex.event();
 const query = fetch bizevents, from:now()-1h | filter LoginKey == "' + c +'" | fields Username, Country, UserId ';
 const response = await queryExecutionClient.queryExecute({ body: { query, requestTimeoutMilliseconds: timeout * 1000, fetchTimeoutSeconds: timeout } });
 
 return response.result;
}

 

Bests

Michal

Hi @MichalOlszewski , thank you for your answer.

You possibly didn't see the image I attached, where I show it being used in a workflow, with the type of DQL.

That solution that you provided, I have it already figured out, I just escape the value to be passed on to the DQL query in a previous action (silly, I know), and then, the problem is not there anymore.

I think this is either a bug, a blatant lapse or I'm just unwise.

I really don't know.

Featured Posts