MSSQL servers logs extracted to loki Grafana dashboard with space in between character's

Hi Team,
Windows environment : Promtail,Loki and Grafana setup
i have setup promtail , loki and grafana dash for extracting the MSSQLserver logs . The logs were displaying on grafana dashboard as below
L o g i n f a i l e d f o r u s e r

Please provide solution how to avoid space between characters.
Ex: instance word is displaying on dash board as i n s t a n c e

Because of the above issue , unable to search for a keywords on dashboard.

1 Like

Same here. Just started down the Loki track and this is one of the first issues I have found. We are a BIG SQL Server shop and these logs are fairly useless for searching

1 Like

Apparently SQL Server Error logs are encoded in UTF-16LE (From Google Searching) Or OCS2-LE BOM (from Notepad++). Grafana Support mentioned changing it to UTF-8, but I don’t think we have the option to change the encoding for SQL Server Error Logs.


are you talking about using Loki to read SQL Server error logs saved to disk?

Yes. MSSQL running on Windows. The ERRORLOG is in UTF-16LE and the Grafana Agent we are using to scrape these logs seems to expect UTF-8.

wow very interesting. Are you copying it out to some other folder or reading it straight from the default location?

Wonder if there is a way of over riding that in either Loki or promtail?

What is this?

Reading it straight from the default location.

another option is to create your own file with the proper encoding using

EXEC xp_ReadErrorLog

1 Like

Or use a scripting language such as python to copy add recreate that file with desired encoding in another location in same location but different extension, I just did that and Loki dashboard looks fine. I just dont see why MS is saving it with such encoding

This is a running sql server that emits logs on a regular frequency. Not sure writing a bunch of wrappers to copy the file (or the current parts of the file) in realtime is practical. We run over 300 SQL Servers and I was looking to Grafana for log capture. I just want the grafana agent to support the encoding.

1 Like

Agreed. Either sql changes their error log encoding or grafana accepts this utf 16.

This is still an issue. Sucks to have to use regex to find “[fF].a.i.l.e.d”, but that is doable. The big issue is the display in either Log Explorer or the log panel. Just impossible to read with the character spaceing.

didn’t this commit fix things?