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

DQL Monthly Query for problems

Eyad
Participant

hi all, i am trying to do Monthly Problem Count and ServiceNow Ticket Count Over the Last 4 Months in one tile.

fetch dt.davis.problems
| summarize TotalProblemMonthly=count(), by:{Month = formatTimestamp(timestamp, format: "MM-yyyy")}
| join [fetch dt.davis.problems
| filter matchesPhrase(labels.alerting_profile,"ServiceNow")
| summarize ServiceNowTickets=count(), by:{Month = formatTimestamp(timestamp, format: "MM-yyyy")}], on:{Month}

the result coming out not sorted i want to sort it based on a month, however if i use sort command will not use the year ad well which is a problem. look at the result image. any recommendation to fix the query to sort it?
Screenshot 2025-02-27 144024.png

3 REPLIES 3

StrangerThing
Advisor

Try putting the year first, and you don't need to do the join.

fetch dt.davis.problems
| summarize TotalProblemMonthly=count(),
ServiceNowTickets=countIf(matchesPhrase(labels.alerting_profile, "ServiceNow")),
by:{Month = formatTimestamp(timestamp, format: "yyyy-MM")}
| sort Month desc

Observability Engineer at FreedomPay

Perfect!, my other question. why it says line graph is unsuitable. if i want the results in graph.

krzysztof_hoja
Dynatrace Champion
Dynatrace Champion

You should use rounded timestamps, not string representation. Also to do proper bar chart it is better to use timerange so single bar spans the time it applies to:

fetch dt.davis.problems
| summarize { TotalProblemMonthly=count() , ServiceNowTickets=countIf(matchesPhrase(labels.alerting_profile, "ServiceNow")) },
  by:{ timeframe=timeframe( from: timestamp@M, to: timestamp@M+1M ) }
| sort timeframe desc

I used time alignment operators: https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-query-language/operators#tim....

Result look like this:

krzysztof_hoja_0-1740729792108.png

krzysztof_hoja_1-1740730602967.png

 

Featured Posts