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

Setting time frame for USQL query

fumax
Visitor

I want to fetch all the xhr actions inside a web application. I am using following usql query(and sending it as a param in GET /api/v1/userSessionQueryLanguage/table

SELECT useraction.name, COUNT(*) AS action_count FROM usersession WHERE useraction.application = 'Temperstack-Local' AND useraction.type = 'Xhr' AND useraction.startTime >= $NOW - DURATION("1d") GROUP BY useraction.name ORDER BY action_count DESC

Where I am facing issue is getting result based on timeframe.
Even if I use: useraction.startTime >= 'yyyy-mm-dd', it won't work.
What works is selecting the desired timeframe in the dynatrace UI.
What exactly am I doing wrong?

3 REPLIES 3

Mizső
DynaMight Guru
DynaMight Guru

Hi @fumax,

I have tired many options without any success. Maybe our synthax is woring.

This option works only form me (becuase $NOW $TIME_FRAME_START are time variables) and  but I think it will not a solution for you which is similar to $NOW:

SELECT useraction.name, COUNT(*) AS action_count FROM usersession WHERE ((useraction.application='Phoenix' OR userevent.application='Phoenix' OR usererror.application='Phoenix')) AND useraction.startTime >=$TIME_FRAME_START - DURATION("1d") GROUP BY useraction.name

Next oprion was the unix time, I have not received any error message (because it a numeric number) but did not work...

SELECT useraction.name, COUNT(*) AS action_count FROM usersession WHERE ((useraction.application='Phoenix' OR userevent.application='Phoenix' OR usererror.application='Phoenix')) AND useraction.startTime >=1723327200 - DURATION("1d") GROUP BY useraction.name

Third option was where the error message clear. 

Mizs_0-1723584299773.png

Maybe other community members have any other ideas.

Best regards,

Mizső

Dynatrace Community RockStar 2024, Certified Dynatrace Professional

Hey @Mizső 
Thank you for your valuable effort and response.

Do you know of any direct api to fetch actions from a web app instead of usql query? 

Mizső
DynaMight Guru
DynaMight Guru

Hi @fumax,

I thnik there is not such API.

You can only use the API which uses USQL.

Mizs_0-1723755573573.png

Best regards,

Mizső

Dynatrace Community RockStar 2024, Certified Dynatrace Professional

Featured Posts