Search code examples
azure-application-insights

Application Insights project literal value of severityLevel


Is there a way to project literal value of severityLevel in Application Insights query?

Consider following query:

union
customEvents,
dependencies,
exceptions,
performanceCounters,
traces
| order by timestamp desc
| project timestamp, operation_Name, itemType, severityLevel, message = strcat(name, message, outerMessage), customDimensions, ['details']

In the output, severityLevel value is numeric, I want the equivalent descriptive value in according with SeverityLevel Enum definition


Solution

    • I am able to get the severityLevel descriptive value.
    • Use the below query snippet
    union
    customEvents,
    dependencies,
    exceptions,
    performanceCounters,
    traces
    | order by timestamp desc
    | project timestamp, operation_Name, itemType, severityLevel, message = strcat(name, message, outerMessage), customDimensions, ['details']
    
    | extend severityLevel = case(severityLevel == 0, "Verbose", 
                           severityLevel == 1, "Information",
                           severityLevel == 2, "Warning", 
                           severityLevel == 3, "Error", 
                           severityLevel == 4, "Critical",                      
                           "-")                                    
    

    enter image description here

    enter image description here