I have a graph that shows me the WS queries that are being made on a server.
In the log, there is the label request, which has the following format: xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-xxxxxxxx.
I would like you to add me by request, taking into account only the first 8 characters of the request, since it is the one that indicates which client it belongs to.
How can I do it?
You can use label_format
and set a label to the value of template + substr
(see Template functions | Grafana Loki documentation), then aggregate on that label. Something like this (not tested):
sum by (first_eight) (
count_over_time(
{SELECTOR} | label_format first_eight=`{{ .request | substr 0 7 }}` [$__auto]
)
)
1 Like
Hi Tony,
It’s worked.
Thank you so much