LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-13-2017, 08:59 AM   #1
harrytk
LQ Newbie
 
Registered: Jul 2011
Posts: 5

Rep: Reputation: Disabled
Rsyslog Filtering


Hi,

I'm trying to configure rsyslog to filter logs being sent by a firewall. I am filtering according to the event id in the logs, which is a string of the form "m=x" where x is the event id number. The firewall has hundreds of such event id's and I only want a small subset of these to appear in my logs.

I am using property based filtering with regex. My problem is that I can successfully configure rsyslog to filter one event id only. When I try to configure more that one event id, it allows everything through without filtering. Below is my working config for one event id:

local0
:msg, regex, "m=14" -/var/log/firewall.log
& stop

If I add a second line for another event id eg:

local0
:msg, regex, "m=14" -/var/log/firewall.log
:msg, regex, "m=15" -/var/log/firewall.log
& stop

then all event id's are processed, not just 14 and 15 as I would like.

Please advise where I am going wrong here.

Many thanks.
 
Old 06-13-2017, 02:39 PM   #2
Linuxfabrik
LQ Newbie
 
Registered: Jun 2017
Posts: 1

Rep: Reputation: Disabled
In Rsyslog v7 and above, filtering is done like so:

Code:
/etc/rsyslog.d/firewall.conf
Code:
if (
    $msg startswith "abc" or 
    $msg startswith "def" or
    ($programname == "kernel" and $msg contains "xyz") or
    ...
   )
then 
    # ignore, do not forward or log
    continue
else
    -/var/log/firewall.log
 
Old 06-19-2017, 03:56 AM   #3
harrytk
LQ Newbie
 
Registered: Jul 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thank you, that method has worked for me. I used:

if ($syslogfacility-text == "local0" and $msg contains "m=14") then -/var/log/firewall.log
else
if ($syslogfacility-text == "local0" and $msg contains "m=35") then -/var/log/firewall.log
 
  


Reply

Tags
filtering, rsyslog


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rsyslog filtering by week mijohnst Linux - Security 14 07-19-2015 04:30 PM
rsyslog filtering syslog messages sanjose Linux - Newbie 13 11-07-2012 03:08 PM
content filtering with layer7- filtering rose1366m Linux - Networking 1 05-04-2011 11:10 AM
rsyslog ytd Linux - Newbie 1 02-11-2011 01:43 AM
Sendmail Spam filtering and Virus filtering MrJoshua Linux - General 2 04-03-2003 10:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration