I would ideally like a visualization where I can see a per-day bar chart of failure provided by loki (via Serilog). The output that serilog is providing looks like the following:
{"Message":"Log message here","Level":"warning","SubField1":"Module1",SubField2:"Process1","SerialNumber":"123456",RunID:"<guid>"}
What I’m seeking is a graph that looks like the following:
Each “Module” is the field in SubField1 (Ignore SubField2). Each day should be its own bar reflecting any “warning”, “error” or “fatal” returned from Serilog and applying to the count for the day (and of course reset to 0 for the next day). What I have so far is the following:
sum by (level) (count_over_time({ApplicationName="MyApp", ApplicationServer="$hostname"} | json | Level =~ `warning|error|fatal` | Message ~= `Acceptable.*|.*rebuild.*` | SubField` = `Module1` [$__range]))
The graph type is Range and Step is 1d (bars of course). While I can write 3 individual queries for the 3 modules, is there a way to do this more efficiently? Is the code even correct for what I am trying to accomplish?