Is there a way to filter logs at the source (content)

This support forum board is for support questions relating to Nagios Log Server, our solution for managing and monitoring critical log data.
Locked
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Is there a way to filter logs at the source (content)

Post by dlukinski »

Hello Nagios Support

Is there a way to filter logs at the source, based on the message body?
- so that only the certain content of the log gets shipped?


Thank you,
Dimitri
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Is there a way to filter logs at the source (content)

Post by ssax »

Are you asking how to limit the content of the logs that get sent to Log Server?

If so, it depends on what you're using to send them, if you're using rsyslog you could setup a filter:

https://www.rsyslog.com/doc/v8-stable/c ... lters.html

For syslog-ng, there is also a filter:

https://www.syslog-ng.com/technical-doc ... ide/filter

What are you using to fire off the logs?
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: Is there a way to filter logs at the source (content)

Post by dlukinski »

ssax wrote:Are you asking how to limit the content of the logs that get sent to Log Server?

If so, it depends on what you're using to send them, if you're using rsyslog you could setup a filter:

https://www.rsyslog.com/doc/v8-stable/c ... lters.html

For syslog-ng, there is also a filter:

https://www.syslog-ng.com/technical-doc ... ide/filter

What are you using to fire off the logs?
Hi

In this case we are shipping DHCP logs (lots of unnecessary messages) from many servers to Nagios LOG via the LOG client and the configuration
attached.

The question is if we could filter and client end first? If not possible, could we filter grok at Nagios LOG end?

Say, I do not need any DHCP messages looking this way: " *Packet dropped because of Client ID hash mismatch or standby server*"

Thank you
You do not have the required permissions to view the files attached to this post.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Is there a way to filter logs at the source (content)

Post by ssax »

Try this:

Code: Select all

<Input windowsfile>
    Module   im_file
    File     "C:\\Windows\\Sysnative\\dhcp\\DhcpSrvLog-*.log"
    SavePos  TRUE
#    ReadFromLast FALSE
    Exec if ($raw_event =~ /Packet dropped because of Client ID hash mismatch or standby server/) drop();
    Exec     $Message = $raw_event;
</Input>
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: Is there a way to filter logs at the source (content)

Post by dlukinski »

ssax wrote:Try this:

Code: Select all

<Input windowsfile>
    Module   im_file
    File     "C:\\Windows\\Sysnative\\dhcp\\DhcpSrvLog-*.log"
    SavePos  TRUE
#    ReadFromLast FALSE
    Exec if ($raw_event =~ /Packet dropped because of Client ID hash mismatch or standby server/) drop();
    Exec     $Message = $raw_event;
</Input>

This worked, and if I wanted only to allow some messages and block the rest?

Thank you
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Is there a way to filter logs at the source (content)

Post by ssax »

Which ones do you want to allow? Is there anything in them that we can exclude (like the event ids or anything)?
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: Is there a way to filter logs at the source (content)

Post by dlukinski »

ssax wrote:Which ones do you want to allow? Is there anything in them that we can exclude (like the event ids or anything)?
Just a question how the rule code should look like:

- say I want to drop ALL messages, but allow one containing "I like this message better" line.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Is there a way to filter logs at the source (content)

Post by ssax »

Try this:

Code: Select all

<Input windowsfile>
    Module   im_file
    File     "C:\\Windows\\Sysnative\\dhcp\\DhcpSrvLog-*.log"
    SavePos  TRUE
#    ReadFromLast FALSE
    Exec if ($raw_event !~ /I like this message better/) drop();
    Exec     $Message = $raw_event;
</Input>
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: Is there a way to filter logs at the source (content)

Post by dlukinski »

ssax wrote:Try this:

Code: Select all

<Input windowsfile>
    Module   im_file
    File     "C:\\Windows\\Sysnative\\dhcp\\DhcpSrvLog-*.log"
    SavePos  TRUE
#    ReadFromLast FALSE
    Exec if ($raw_event !~ /I like this message better/) drop();
    Exec     $Message = $raw_event;
</Input>

I see.

Thank you, please close the case
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Is there a way to filter logs at the source (content)

Post by cdienger »

Glad to hear it's working!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked