DQL
Questions about Dynatrace Query Language
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Store the moment a value changes in a field

Red
Participant

Hello community,

I'm trying to do something with DQL, but I'm not even sure it's possible. To give you some context, I have a DQL query to display Control-M jobs that are retrieved using the following extension:

timeseries { avg(controlm.job.status), value.A = avg(controlm.job.status, scalar: true) }, by: { `dt.entity.controlm:job` }
| lookup sourceField:`dt.entity.controlm:job`, lookupField:id, [
  fetch `dt.entity.controlm:job`
  | fieldsAdd application, description, subapplication, orderdate
]

This query displays the status of the jobs as a percentage. For example, a job waiting to pass is at 25%, a job OK is at 100%, etc.

The problem is, there's no field that contains the information about when the job executes and passes (OK or KO). I only have the graph showing the percentage change:

Red_0-1777971140771.png

 

My question is: is it possible to "store" the hour and minute when the value changed from 25% to 100%? The goal is to have a table, not a graph, displaying the job status and time of each job (like the one below, but with an additional column showing the exact time of each job):

Red_1-1777971186912.png

 

If you have any suggestions, I'd appreciate them.

 

Best regards,

Red

1 REPLY 1

krzysztof_hoja
Dynatrace Champion
Dynatrace Champion

If you use metrics to store your data, it is impossible to know exact moment of change. By definition data is assigned to time buckets and this way it is rounded to 1m.

Of course you can run analysis of timeseries to track the changes. Right now with iterative expressions and arrayElement() function you can compare easily subsequent elements in array. Here is example DQL query getting last change from 25 to 100 in timeseries. Of course you can adjust the logic as you wish:

data record(a=array(25.0, 25.0, 25.0, 25.0, 100.0, 100.0), timeframe=timeframe(from:@m-6m, to: @m), interval=1m) 
| fieldsAdd c = if( a[]==100 and arrayElement(a, iIndex()-1)==25.0, timeframe[start]+iIndex()*interval )
| fieldsAdd c = arrayLast(c)

 

krzysztof_hoja_0-1779262838556.png

 

 

Featured Posts