Невозможно заставить многострочные операторы rsyslog фильтровать входящие системные журналы в разные файлы. - PullRequest
0 голосов
/ 23 февраля 2019

Я пробовал это так много разных способов.У меня есть входящий поток системного журнала на порт 1522 с прокси-сервера.Я пытаюсь сопоставить часть сообщения / тела "location =" и отправить каждый журнал из определенного места в свой собственный файл.Я сделал это в небольшом масштабе, но никогда не использовал длинную многострочную.

Пример системного журнала:

Feb 22 22:59:51 192.168.0.126 |2019-02-22 22:58:20|reason=Allowed|event_id=6660962988918112262|protocol=HTTP|action=Allowed|transactionsize=8374|responsesize=6073|requestsize=2301|urlcategory=Internet Services|serverip=52.114.76.34|clienttranstime=125000|requestmethod=CONNECT|refererURL=None|useragent=Unknown|product=NSS|location=ABC Corporation|ClientIP=192.168.1.152|status=200|user=ABC Corporation|url=mobile.pipe.aria.microsoft.com|vendor=Zscaler|hostname=mobile.pipe.aria.microsoft.com|clientpublicIP=192.65.41.5|threatcategory=Clean Transaction|threatname=None|filetype=None|appname=Common Office 365 Applications|pagerisk=0|department=Default Department|urlsupercategory=Internet Communication|appclass=Business|dlpengine=None|urlclass=Business Use|threatclass=Clean Transaction|dlpdictionaries=None|fileclass=None|bwthrottle=NO|servertranstime=125000

Я пробовал следующие варианты в моем / etc /Файл rsyslog.d / networks.conf, но ни один из них не соответствует местоположению и направлен на разные файлы:

TAKE-1:

template(name="abc-zscaler-web" type="string" string="/var/rsyslog/zscaler-web/%FROMHOST%/abc-%$year%-%$month%-%$day%.log")
template(name="def-zscaler-web" type="string" string="/var/rsyslog/zscaler-web/%FROMHOST%/def-%$year%-%$month%-%$day%.log")
template(name="ghi-zscaler-web" type="string" string="/var/rsyslog/zscaler-web/%FROMHOST%/ghi-%$year%-%$month%-%$day%.log")
$RuleSet Remote1522
$RuleSet CreateMainQueue on
if $msg contains 'location=ABC ' then {action(type="omfile" DynaFile="abc-zscaler-web") stop}
if $msg contains 'location=DEF ' then {action(type="omfile" DynaFile="def-zscaler-web") stop}
if $msg contains 'location=GHI ' then {action(type="omfile" DynaFile="ghi-zscaler-web") stop}
*.* then {action(type="omfile" DynaFile="abc-zscaler-web") stop}
$InputTCPServerBindRuleset Remote1522
$InputTCPServerRun 1522

TAKE-2:

$RuleSet Remote1522
$RuleSet CreateMainQueue on
if $msg contains "location=ABC " then /var/rsyslog/zscaler-web/%FROMHOST%/abc-%$year%-%$month%-%$day%.log
if $msg contains "location=ABC " then stop
if $msg contains "location=DEF " then /var/rsyslog/zscaler-web/%FROMHOST%/def-%$year%-%$month%-%$day%.log
if $msg contains "location=DEF " then stop
if $msg contains "location=GHI " then /var/rsyslog/zscaler-web/%FROMHOST%/ghi-%$year%-%$month%-%$day%.log
if $msg contains "location=GHI " then stop
*.* /var/rsyslog/zscaler-web/%FROMHOST%/abc-%$year%-%$month%-%$day%.log
$InputTCPServerBindRuleset Remote1522
$InputTCPServerRun 1522

TAKE-3

$RuleSet Remote1522
$RuleSet CreateMainQueue on
if ( $msg contains 'location=ABC ') then {
               action(type="omfile" file="/var/rsyslog/zscaler-web/%FROMHOST%/abc-%$year%-%$month%-%$day%.log")
}      else if ($msg contains 'location=DEF ') then {
               action(type="omfile" file="/var/rsyslog/zscaler-web/%FROMHOST%/def-%$year%-%$month%-%$day%.log")
}      else if ($msg contains 'location=GHI ') then {
               action(type="omfile" file="/var/rsyslog/zscaler-web/%FROMHOST%/ghi-%$year%-%$month%-%$day%.log")
}      else {action(type="omfile" file="/var/rsyslog/zscaler-web/%FROMHOST%/abc-%$year%-%$month%-%$day%.log")
}
$InputTCPServerBindRuleset Remote1522
$InputTCPServerRun 1522

TAKE-4 ( есть еще, но этопоследний значащий )

$template abc-zscaler-web,"/var/rsyslog/zscaler-web/%FROMHOST%/abc-%$year%-%$month%-%$day%.log"
$template def-zscaler-web,"/var/rsyslog/zscaler-web/%FROMHOST%/def-%$year%-%$month%-%$day%.log"
$template ghi-zscaler-web,"/var/rsyslog/zscaler-web/%FROMHOST%/ghi-%$year%-%$month%-%$day%.log"
$RuleSet Remote1522
$RuleSet CreateMainQueue on
if $msg contains 'location=ABC ' then -?abc-zscaler-web
if $msg contains 'location=ABC ' then stop
if $msg contains 'location=DEF ' then -?def-zscaler-web
if $msg contains 'location=DEF ' then stop
if $msg contains 'location=GHI ' then -?ghi-zscaler-web
if $msg contains 'location=GHI ' then stop
*.*  -?abc-zscaler-web
$InputTCPServerBindRuleset Remote1522
$InputTCPServerRun 1522

Я что-то упустил в моих скриптах-реинерах.Код / места были продезинфицированы, чтобы защитить невинных.

1 Ответ

0 голосов
/ 24 февраля 2019

Я не знаю, является ли это просто ошибкой в ​​вашей копии здесь, но строка

$RuleSet CreateMainQueue on

должна быть

$RuleSetCreateMainQueue on

Если бы вы проверяли синтаксисваш файл конфигурации сервера с чем-то вроде rsyslogd -N1 -f server.conf вы бы увидели ошибку:

rsyslogd: error: extra characters in config line ignored: 'on'

Конечным результатом является то, что вы определяете набор правил с именем CreateMainQueue вместо Remote1522 .

...