I have this expression in my splunk query eval A = A + '/' + B where A is the new variable (column name) to which I am assigning the values of A and B from my log line and I need to replace the same expression in loki grafana using logql. Right now I am just getting two columns Time and {}. I want to replaace TIme column with eval expression. Can someone please help me on this?
The equivalent of variables in LogQL are labels.
Thus, you can use label_format
to achieve what you want.
Here is an example of how to use label_format
to perform a string concatenation of two labels, named var_a
and var_b
:
Input:
{"var_a": "a", "var_b": "b", "message": "hello there!"}
LogQL query :
{service="my-awesome-app"}
| json # or logfmt, depending on your log format
| label_format var_a=`{{.var_a}}/{{.var_b}}` # this reassigns var_a based on the given template
Output:
{"var_a": "a/b", "var_b": "b", "message": "hello there!"}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.