I’m working on a very low end system, and I was looking for ways to remove influxdb from my log pipeline, as it can be a bit heavy, especially on memory use.
I discovered Loki - ‘like prometheus but for logs’. Telegraf has a Loki output plugin, so I went for that.
Basically it works, I’m getting logs in my grafana dashboard, but they’re pretty messed up.
I get a ‘labels’ value, for example { “__name”: “syslog”, “appname”: “grafana-server”, “facility”: “daemon”, “host”: “iota”, “hostname”: “iota”, “severity”: “info”, “source”: “127.0.0.1” }.
I also get a ‘Line’ value:
facility_code=“3” severity_code=“6” timestamp=“1687865491000000000” procid=“186713” message=“logger=context userId=1 orgId=1 uname=admin t=2023-06-27T14:31:31.799826078+03:00 level=error msg=“Request error” error=“net/http: abort Handler”” version=“1”
Now the very short documentation for this Loki output plugin recommends to use ‘| logfmt’ on the lokiql query. This doesn’t work for most of these logs:
{ “Request”: “”, “error”: “LogfmtParserErr”, “error_details”: “logfmt syntax error at pos 206 : unexpected ‘"’”, “__name”: “syslog”, “appname”: “grafana-server”, “facility”: “daemon”, “facility_code”: “3”, “host”: “iota”, “hostname”: “iota”, “message”: “logger=context userId=1 orgId=1 uname=admin t=2023-06-27T14:31:31.799826078+03:00 level=error msg=”, “procid”: “186713”, “severity”: “info”, “severity_code”: “6”, “source”: “127.0.0.1”, “timestamp”: “1687865491000000000” }
The message value has a msg=“” in it and it seems to break it.
Alternatively, I could use a pattern operator to grab the message, however, the values in the Line column are all randomly ordered, sometimes it begins with a procid, other times timestamp etc.
Is there any way I could sort these Lines to have the same pattern? If anyone has used the Loki output in telegraf I’d appreciate a nudge to ge these logs sorted out.