Skip to content

Visualizing log level in Grafana

Mykhailo Shevchuk edited this page Jun 5, 2026 · 3 revisions

TL;DR

By default the sink attaches a level stream label to every event, using Grafana's level vocabulary. Grafana uses this label to colour and filter logs out of the box.

This is controlled by handleLogLevelAsLabel, which is true by default. Set it to false if you don't want the label.

Level mapping

Serilog levels map to Loki/Grafana level names:

Serilog level Loki level value
Verbose trace
Debug debug
Information info
Warning warning
Error error
Fatal fatal

In v8 and earlier Fatal was emitted as critical. From v9 it is fatal, matching Grafana's own vocabulary. Update any dashboards or alert rules that match on critical.

Disabling the label

.WriteTo.GrafanaLoki(
    "http://localhost:3100",
    handleLogLevelAsLabel: false)
{
  "Name": "GrafanaLoki",
  "Args": {
    "uri": "http://localhost:3100",
    "handleLogLevelAsLabel": false
  }
}

If you turn the label off

With handleLogLevelAsLabel: false the level is not added as a label, and LokiJsonTextFormatter does not copy it into the JSON body either. If you still need the level queryable, surface it with a custom Serilog enricher that writes LogEvent.Level into a property.

level is a low-cardinality label, so leaving it on (the default) is the simplest and recommended option.

Clone this wiki locally