Sum of values from a field after pattern

Is it possible to do some kind of sum with the content of fields after it has gone trough a pattern.

For example the following loki quey results in lines only containing >0 records.

{filename=~"/DIR/server/cur/server.*log",host=“localhost”}!~".SomeStrring."| pattern "<RS_Code> | | | Project = , transactions processed since , next statistical log at: " | records>0

My goal is to sum the number of records per Project

What im looking for is a sum or show a label in a graph.

For instance this query has a label with processtime. I wanted to show that in a graph of some sort.

{env="prod", filename=~"/mylog/server-.*log", host="myhost"} |~ `finished reading` | pattern `<RSCode> | <Date> <Time> | <ReturnCode> | [<Service>]<Div> finished reading file <File> in <ProcessTime> ms`

Can labels be used to do these kind of things?
Or should i parse this is some way with promtail itself? And if so how?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.