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

DQL query to replace null values into an integer in a array

Elumalai
Newcomer

Hi Team,

I'm using single synthetic monitoring configuration where I have configured 3 http requests and I would like to monitor all 3 http url in a dashboard. If any http url receives status code other than 200 then it should fail.

I use below DQL query to fetch the metrics, the average value dt.synthetic.http.request.executions comes 1 if there is a success and gives null when it fails.

When I try to fetch arraylast() value, DQL ignores all null values and picks latest numerical value from an array. Is there a function to change null values into numerical value i.e 0 so that I can pick that value and mark my application down.

timeseries requests = avg(dt.synthetic.http.request.executions),
filter: { http_monitor.result.http_status.code == 200 AND matchesValue(entityAttr(dt.entity.http_check_step, "entity.name"), "test-monitor") }
| fieldsAdd final=if(arrayLast(requests)==1, "UP", else: "DOWN")

2 REPLIES 2

marina_pollehn
DynaMight Champion
DynaMight Champion

Can you try this? 🙂

timeseries requests = avg(dt.synthetic.http.request.executions),
filter: { http_monitor.result.http_status.code == 200 AND matchesValue(entityAttr(dt.entity.http_check_step, "entity.name"), "test-monitor") }
| fieldsAdd requests =if(isNull(requests[]),0,else:requests[])

| fieldsAdd final=if(arrayLast(requests)==1, "UP", else: "DOWN")

A Dynatrace Professional nerd working for Conclusion Xforce

Elumalai
Newcomer

This works, much appreciated

Featured Posts