1

I'm a beginer for Grafana Loki, and now we have a running instance which works without issue (can see the log itself), now we want to define some variables and monitors them in the dashboard.

Below is one of our log froward from promtail->loki->grafana, belongs to job "mqtt_log", we want to extract the "534654234" and the "1" from the log as two variable, and monitor in the dashboard.

2022-11-02 12:16:23 mqtt_log 2022-11-02 12:16:23,428 - AliyunMqtt - INFO - elevator/534654234/cabin/position/: b'{"Name":"Group.Elevators{EquipmentNumber=534654234}.Cabins:0.Position","Value":"{"Group":"1"}","Representation":"Live","TimeStamp":1667362583365}'

The problem is we don't know how to define the variables, anyone can share some comments, thanks.

Jan Garaj
  • 25,598
  • 3
  • 38
  • 59
Sgnes
  • 11
  • 3

1 Answers1

0

You can't create dynamic (only hardcoded) dashboard variable from the parsed logs. You can do that only from existing labels.

Jan Garaj
  • 25,598
  • 3
  • 38
  • 59
  • Thanks for the comments, does this mean I have to write regex to parse the log in promtail to create the labels, then I can use it in dashboard, thanks. – Sgnes Nov 03 '22 at 00:31