Create Grafana Alert that scans log files for specific words

Hello everyone,

I’ve spent hours googling and watching YouTube videos and unfortunately haven’t found a solution. I have to say that I am a total beginner.

I’m logging a txt file with Loki and would like to set an alert that reports when a certain word occurs in the file, for example Error. Can someone help me with how exactly I have to set this up? Many thanks in advance

Something like:

sum( count_over_time ( {service_name=~`.*`} |= `ERROR    No data seen in 2 minutes: restarting` [10m]))

( i use this as a recoding rule as well)

I would like to read a log file that is on a server. Then I would have to use the filename instead of the service_name, right? The other question would then be what I have to set below

Yes, using filename ( or whatever filter matches…) woud work.

Then just look at the output of your query(e.g. in explore) to find a suitable threshold.