systemd-journaldsystemd-journal-remote

How to monitor JournalD for Error/Fatal error messages of some particular process and start some callback if any


How to monitor JournalD for Error/Fatal error messages of some particular process and start some callback if any. Say if some service - say Nginx posts a log with Error - some script would call. How to make such a script?


Solution

  • You have to use journalctl --unit darts-game-server.service --follow -o json stream and parse the output in your code. There are libs for that as well.