Skip to content

Commit e974ff3

Browse files
authored
[202305][rsyslog]: Remote logging with the highest rule priority (#21993)
Why I did it This fix resolves issue with missing certain types of messages while forwarding to the remote server. Basically, this moves remote syslog forwarding rules to be executed before any other instructions take place, so everything received by a local syslog instance will be forwarded to the remote machine. The fix allows remote forwarding of messages defined as: https://github.com/sonic-net/sonic-buildimage/blob/master/files/image_config/rsyslog/rsyslog.d/00-sonic.conf.j2 Work item tracking N/A How I did it Moved rsyslog remote forwarding rules to be on top of other syslog instructions How to verify it Enable remote syslog forwarding Check for message patterns defined as 00-sonic.conf.j2
1 parent 2f68400 commit e974ff3

File tree

4 files changed

+34
-40
lines changed

4 files changed

+34
-40
lines changed

files/image_config/rsyslog/rsyslog.conf.j2

+28-28
Original file line numberDiff line numberDiff line change
@@ -58,34 +58,6 @@ template(name="WelfRemoteFormat" type="string" string="%TIMESTAMP% id=firewall t
5858
:::date-year%-%timereported:::date-month%-%timereported:::date-day% %timereported:::date-hour%:%timereported:::date-minute%:%timereported\
5959
:::date-second%\" fw=\"{{ fw_name }}\" pri=%syslogpriority% msg=\"%syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\"\n")
6060

61-
#
62-
# Set the default permissions for all log files.
63-
#
64-
$FileOwner root
65-
$FileGroup adm
66-
$FileCreateMode 0640
67-
$DirCreateMode 0755
68-
$Umask 0022
69-
70-
#
71-
# Where to place spool and state files
72-
#
73-
$WorkDirectory /var/spool/rsyslog
74-
75-
#
76-
# Include all config files in /etc/rsyslog.d/
77-
#
78-
$IncludeConfig /etc/rsyslog.d/*.conf
79-
80-
#
81-
# Suppress duplicate messages and report "message repeated n times"
82-
#
83-
$RepeatedMsgReduction on
84-
85-
###############
86-
#### RULES ####
87-
###############
88-
8961
#
9062
# Remote syslog logging
9163
#
@@ -128,3 +100,31 @@ $RepeatedMsgReduction on
128100
*.{{ severity }}
129101
action(type="omfwd" Target="{{ server }}" Port="{{ port }}" Protocol="{{ proto }}" Template="{{ template }}"{{ options }})
130102
{% endfor %}
103+
104+
#
105+
# Set the default permissions for all log files.
106+
#
107+
$FileOwner root
108+
$FileGroup adm
109+
$FileCreateMode 0640
110+
$DirCreateMode 0755
111+
$Umask 0022
112+
113+
#
114+
# Where to place spool and state files
115+
#
116+
$WorkDirectory /var/spool/rsyslog
117+
118+
#
119+
# Include all config files in /etc/rsyslog.d/
120+
#
121+
$IncludeConfig /etc/rsyslog.d/*.conf
122+
123+
#
124+
# Suppress duplicate messages and report "message repeated n times"
125+
#
126+
$RepeatedMsgReduction on
127+
128+
###############
129+
#### RULES ####
130+
###############

src/sonic-config-engine/setup.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[aliases]
2+
test=pytest

src/sonic-config-engine/tests/test_cfggen_from_yang.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,10 @@ def test_portchannel_table(self):
104104
assert(output == \
105105
{'PortChannel1001': {'admin_status': 'up',
106106
'lacp_key': 'auto',
107-
'members': ['Ethernet0', 'Ethernet4'],
108107
'min_links': '1',
109108
'mtu': '9100'},
110109
'PortChannel1002': {'admin_status': 'up',
111110
'lacp_key': 'auto',
112-
'members': ['Ethernet16', 'Ethernet20'],
113111
'min_links': '1',
114112
'mtu': '9100'}})
115113

@@ -194,7 +192,8 @@ def test_acl_rule(self):
194192
"EVERFLOW|Rule2": {
195193
"DST_IP": "192.169.10.1/32",
196194
"SRC_IP": "10.10.1.1/16",
197-
"IP_TYPE": "IPV4"
195+
"IP_TYPE": "IPV4",
196+
"PRIORITY": "101"
198197
}
199198
})
200199

src/sonic-config-engine/tests/test_yang_data.json

+2-9
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,13 @@
9898
"PORTCHANNEL_LIST": [
9999
{
100100
"admin_status": "up",
101-
"members": [
102-
"Ethernet0",
103-
"Ethernet4"
104-
],
105101
"min_links": "1",
106102
"mtu": "9100",
107103
"lacp_key": "auto",
108104
"name": "PortChannel1001"
109105
},
110106
{
111107
"admin_status": "up",
112-
"members": [
113-
"Ethernet16",
114-
"Ethernet20"
115-
],
116108
"min_links": "1",
117109
"mtu": "9100",
118110
"lacp_key": "auto",
@@ -300,7 +292,8 @@
300292
"DST_IP": "192.169.10.1/32",
301293
"SRC_IP": "10.10.1.1/16",
302294
"IP_TYPE": "IPV4",
303-
"RULE_NAME": "Rule2"
295+
"RULE_NAME": "Rule2",
296+
"PRIORITY": 101
304297
}
305298
]
306299
}

0 commit comments

Comments
 (0)