How to get mariadb slow query log

Hello there

I am using ubuntu 20.04 and graylog 4.2.6.
I’m currently receiving multiple logs from one server to syslog and gelf and I have several of these servers.

Now I want to get logs of slow queries in mariadb, but most people seem to use sidecar.
But I’d like to use gelf rather than sidecar if possible.
It seems difficult because rsyslog is already being used for sending other logs.
What do I need to put in the script to extract the log to gelf?

I need your help as I’m not very good with shell scripts and greylogs. :joy:


Sidecar is just a wrapper for “Winlogbeat, FileBeat, MetricBeat, Nxlog”, you can install these separate.
Example for Nxlog you can use this to pick up MongoDb Slow Query logs

<Input in>
    Module       im_file
    FILE         "/var/log/mongodb/mongodb_slow.log"
    SavePos       TRUE
    ReadFromLast  TRUE
    PollInterval  1
    Exec  $Message = $raw_event;

or FileBeat

- input_type: log
    - /var/log/mongodb/mongodb_slow.log
  type: log

Hope that helps


It took a long time, but I finally did it!
Thanks for your help :smiling_face: :smiling_face: :smiling_face:

1 Like

Nice :smiley: Glad I could help

1 Like

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