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

How to use ENUM in code while building a dashboard?

TomLichti
Contributor

I asked this in the Dev Q&A forum, but this forum might have more visibility.

As a test use case I am building a dashboard that lists problems, with a Severity variable. I have done it successfully using a CSV list of the Severity Levels, but in the API there is an existing ENUM of the levels called ProblemSeverityLevel which should have all of them, but I can't figure out how to use that in code. If I reference if from the problemsClient, it just returns null, or invalid reference, depending on how I try to use it. Is it possible to reference the ENUM so I can then list the values into the variable via code? 

2 REPLIES 2

IzabelaRokita
Community Team
Community Team

Hello @TomLichti ,
Have you found the answer to your question already? If not - let me know, I'll try to find someone to assist you 🙂 

LawrenceBarratt
Dynatrace Advisor
Dynatrace Advisor

Hi @TomLichti 

Dynatrace Severities are - Availability, Error, Slowdown, Resource, Custom

Have you tried this using DQL?

This DQL snippet will give you a summary of problems by severity

fetch events
| filter event.kind == "DAVIS_PROBLEM"
| summarize CurrentTime = takeLast(timestamp), by:{display_id, event.category}
| summarize ProblemCount = countDistinct(display_id),by:{event.category}

LawrenceBarratt_0-1704835640961.png

Remove the last line and it will give you a list of problems with their most recent event status

fetch events
| filter event.kind == "DAVIS_PROBLEM"
| summarize CurrentTime = takeLast(timestamp), by:{display_id, event.category}
//| summarize ProblemCount = countDistinct(display_id),by:{event.category}

LawrenceBarratt_1-1704835750013.png

 

Add this to a dashboard and you can use the below DQL snippets for the variable and filter by event.category

// Dashboard Variable
fetch events
| filter event.kind == "DAVIS_PROBLEM"
| summarize CurrentTime = takeLast(timestamp), by:{display_id, event.category}
| summarize ProblemCount = countDistinct(display_id),by:{event.category}
| fields event.category
//DQL Query Tile
fetch events
| filter event.kind == "DAVIS_PROBLEM"
| summarize CurrentTime = takeLast(timestamp), by:{display_id, event.category}
| filter in(event.category, array($Severity))

LawrenceBarratt_3-1704836006068.png

LawrenceBarratt_2-1704835994038.png

Let me know if you have any further questions.

Thanks,

Lawrence

Featured Posts