Monitor single Log File

I´m looking for a tool or a skript for monitoring 1 single Log file. I´d like to get a notification via telegram if the log file containes a word I´m passing to it.

My approach:

 #!/bin/sh tail -f /var/log/named/named.log | while read line do cat /foo/bar/grepThisWords | while read test do case "$line" in *"$test"*) [my TG-Curl Notification with "$test found"] esac done done

I planned to run this skript as a daemon 24/7 but it does not work like i want it to work. When I run it in Shell like ./skript.sh it shows the last logs and sends me notifications. It Works nearly okay, but I couldnt make it a Daemon and running 24/7.

Looking forward for helping answers!

Thank you

2 Answers

I found a way to monitor single files: The tool inotifywait does exactly what I needed!

inotifywait -e modify /for/bar/file | while read t; do if t ~= *test*
[...]

You could try the suggestions here to use Telegraf:

I have used Prometheus myself for monitoring but not for log monitoring. I understand the Prometheus Blackbox Exporter has some sort of log monitoring capability but I have not used it.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like