Skip to content

Commit a8ad19d

Browse files
[202305] Optimize syslog rate limit feature for fast and warm boot (#17478)
Backport PR #17458 due to conflict. Why I did it Optimize syslog rate limit feature for fast and warm boot Work item tracking Microsoft ADO (number only): How I did it Optimize redis start time Don't render rsyslog.conf in container startup script Disable containercfgd by default. There is a new CLI to enable it (in another PR) How to verify it Manual test Regression test
1 parent 690c4c5 commit a8ad19d

File tree

21 files changed

+455
-78
lines changed

21 files changed

+455
-78
lines changed

dockers/docker-base-bullseye/Dockerfile.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ RUN apt-get clean -y && \
119119
apt-get autoremove -y && \
120120
rm -rf /var/lib/apt/lists/* /tmp/* ~/.cache
121121

122+
COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"]
122123
COPY ["etc/rsyslog.d/*", "/etc/rsyslog.d/"]
123124
COPY ["root/.vimrc", "/root/.vimrc"]
124125

125126
RUN ln /usr/bin/vim.tiny /usr/bin/vim
126127

127128
COPY ["etc/supervisor/supervisord.conf", "/etc/supervisor/"]
128-
COPY ["etc/supervisor/containercfgd.conf", "/etc/supervisor/conf.d/"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#
2+
# /etc/rsyslog.conf Configuration file for rsyslog.
3+
#
4+
# For more information see
5+
# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html
6+
7+
8+
#################
9+
#### MODULES ####
10+
#################
11+
12+
$ModLoad imuxsock # provides support for local system logging
13+
14+
#
15+
# Set a rate limit on messages from the container
16+
#
17+
$SystemLogRateLimitInterval 300
18+
$SystemLogRateLimitBurst 20000
19+
20+
#$ModLoad imklog # provides kernel logging support
21+
#$ModLoad immark # provides --MARK-- message capability
22+
23+
# provides UDP syslog reception
24+
#$ModLoad imudp
25+
#$UDPServerRun 514
26+
27+
# provides TCP syslog reception
28+
#$ModLoad imtcp
29+
#$InputTCPServerRun 514
30+
31+
32+
###########################
33+
#### GLOBAL DIRECTIVES ####
34+
###########################
35+
36+
set $.CONTAINER_NAME=getenv("CONTAINER_NAME");
37+
38+
# Set remote syslog server
39+
template (name="ForwardFormatInContainer" type="string" string="<%PRI%>%TIMESTAMP:::date-rfc3339% %HOSTNAME% %$.CONTAINER_NAME%#%syslogtag%%msg:::sp-if-no-1st-sp%%msg%")
40+
*.* action(type="omfwd" target=`echo $SYSLOG_TARGET_IP` port="514" protocol="udp" Template="ForwardFormatInContainer")
41+
42+
#
43+
# Use traditional timestamp format.
44+
# To enable high precision timestamps, comment out the following line.
45+
#
46+
#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
47+
48+
# Define a custom template
49+
$template SONiCFileFormat,"%TIMESTAMP%.%timestamp:::date-subseconds% %HOSTNAME% %syslogseverity-text:::uppercase% %$.CONTAINER_NAME%#%syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
50+
$ActionFileDefaultTemplate SONiCFileFormat
51+
52+
#
53+
# Set the default permissions for all log files.
54+
#
55+
$FileOwner root
56+
$FileGroup adm
57+
$FileCreateMode 0640
58+
$DirCreateMode 0755
59+
$Umask 0022
60+
61+
#
62+
# Where to place spool and state files
63+
#
64+
$WorkDirectory /var/spool/rsyslog
65+
66+
#
67+
# Include all config files in /etc/rsyslog.d/
68+
#
69+
$IncludeConfig /etc/rsyslog.d/*.conf
70+
71+
#
72+
# Suppress duplicate messages and report "message repeated n times"
73+
#
74+
$RepeatedMsgReduction on
75+
76+
###############
77+
#### RULES ####
78+
###############

dockers/docker-base-buster/Dockerfile.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ RUN apt-get clean -y && \
117117
apt-get autoremove -y && \
118118
rm -rf /var/lib/apt/lists/* /tmp/* ~/.cache/
119119

120+
COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"]
120121
COPY ["etc/rsyslog.d/*", "/etc/rsyslog.d/"]
121122
COPY ["root/.vimrc", "/root/.vimrc"]
122123

123124
RUN ln /usr/bin/vim.tiny /usr/bin/vim
124125

125126
COPY ["etc/supervisor/supervisord.conf", "/etc/supervisor/"]
126-
COPY ["etc/supervisor/containercfgd.conf", "/etc/supervisor/conf.d/"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#
2+
# /etc/rsyslog.conf Configuration file for rsyslog.
3+
#
4+
# For more information see
5+
# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html
6+
7+
8+
#################
9+
#### MODULES ####
10+
#################
11+
12+
$ModLoad imuxsock # provides support for local system logging
13+
14+
#
15+
# Set a rate limit on messages from the container
16+
#
17+
$SystemLogRateLimitInterval 300
18+
$SystemLogRateLimitBurst 20000
19+
20+
#$ModLoad imklog # provides kernel logging support
21+
#$ModLoad immark # provides --MARK-- message capability
22+
23+
# provides UDP syslog reception
24+
#$ModLoad imudp
25+
#$UDPServerRun 514
26+
27+
# provides TCP syslog reception
28+
#$ModLoad imtcp
29+
#$InputTCPServerRun 514
30+
31+
32+
###########################
33+
#### GLOBAL DIRECTIVES ####
34+
###########################
35+
36+
set $.CONTAINER_NAME=getenv("CONTAINER_NAME");
37+
38+
# Set remote syslog server
39+
template (name="ForwardFormatInContainer" type="string" string="<%PRI%>%TIMESTAMP:::date-rfc3339% %HOSTNAME% %$.CONTAINER_NAME%#%syslogtag%%msg:::sp-if-no-1st-sp%%msg%")
40+
*.* action(type="omfwd" target=`echo $SYSLOG_TARGET_IP` port="514" protocol="udp" Template="ForwardFormatInContainer")
41+
42+
#
43+
# Use traditional timestamp format.
44+
# To enable high precision timestamps, comment out the following line.
45+
#
46+
#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
47+
48+
# Define a custom template
49+
$template SONiCFileFormat,"%TIMESTAMP%.%timestamp:::date-subseconds% %HOSTNAME% %syslogseverity-text:::uppercase% %$.CONTAINER_NAME%#%syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
50+
$ActionFileDefaultTemplate SONiCFileFormat
51+
52+
#
53+
# Set the default permissions for all log files.
54+
#
55+
$FileOwner root
56+
$FileGroup adm
57+
$FileCreateMode 0640
58+
$DirCreateMode 0755
59+
$Umask 0022
60+
61+
#
62+
# Where to place spool and state files
63+
#
64+
$WorkDirectory /var/spool/rsyslog
65+
66+
#
67+
# Include all config files in /etc/rsyslog.d/
68+
#
69+
$IncludeConfig /etc/rsyslog.d/*.conf
70+
71+
#
72+
# Suppress duplicate messages and report "message repeated n times"
73+
#
74+
$RepeatedMsgReduction on
75+
76+
###############
77+
#### RULES ####
78+
###############

dockers/docker-base-buster/etc/supervisor/containercfgd.conf

-9
This file was deleted.

dockers/docker-base-stretch/Dockerfile.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ RUN apt-get clean -y && \
113113
apt-get autoremove -y && \
114114
rm -rf /var/lib/apt/lists/* /tmp/*
115115

116+
COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"]
116117
COPY ["etc/rsyslog.d/*", "/etc/rsyslog.d/"]
117118
COPY ["root/.vimrc", "/root/.vimrc"]
118119

119120
RUN ln /usr/bin/vim.tiny /usr/bin/vim
120121

121122
COPY ["etc/supervisor/supervisord.conf", "/etc/supervisor/"]
122-
COPY ["etc/supervisor/containercfgd.conf", "/etc/supervisor/conf.d/"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#
2+
# /etc/rsyslog.conf Configuration file for rsyslog.
3+
#
4+
# For more information see
5+
# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html
6+
7+
8+
#################
9+
#### MODULES ####
10+
#################
11+
12+
$ModLoad imuxsock # provides support for local system logging
13+
14+
#
15+
# Set a rate limit on messages from the container
16+
#
17+
$SystemLogRateLimitInterval 300
18+
$SystemLogRateLimitBurst 20000
19+
20+
#$ModLoad imklog # provides kernel logging support
21+
#$ModLoad immark # provides --MARK-- message capability
22+
23+
# provides UDP syslog reception
24+
#$ModLoad imudp
25+
#$UDPServerRun 514
26+
27+
# provides TCP syslog reception
28+
#$ModLoad imtcp
29+
#$InputTCPServerRun 514
30+
31+
32+
###########################
33+
#### GLOBAL DIRECTIVES ####
34+
###########################
35+
36+
set $.CONTAINER_NAME=getenv("CONTAINER_NAME");
37+
38+
# Set remote syslog server
39+
template (name="ForwardFormatInContainer" type="string" string="<%PRI%>%TIMESTAMP:::date-rfc3339% %HOSTNAME% %$.CONTAINER_NAME%#%syslogtag%%msg:::sp-if-no-1st-sp%%msg%")
40+
*.* action(type="omfwd" target=`echo $SYSLOG_TARGET_IP` port="514" protocol="udp" Template="ForwardFormatInContainer")
41+
42+
#
43+
# Use traditional timestamp format.
44+
# To enable high precision timestamps, comment out the following line.
45+
#
46+
#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
47+
48+
# Define a custom template
49+
$template SONiCFileFormat,"%TIMESTAMP%.%timestamp:::date-subseconds% %HOSTNAME% %syslogseverity-text:::uppercase% %$.CONTAINER_NAME%#%syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
50+
$ActionFileDefaultTemplate SONiCFileFormat
51+
52+
#
53+
# Set the default permissions for all log files.
54+
#
55+
$FileOwner root
56+
$FileGroup adm
57+
$FileCreateMode 0640
58+
$DirCreateMode 0755
59+
$Umask 0022
60+
61+
#
62+
# Where to place spool and state files
63+
#
64+
$WorkDirectory /var/spool/rsyslog
65+
66+
#
67+
# Include all config files in /etc/rsyslog.d/
68+
#
69+
$IncludeConfig /etc/rsyslog.d/*.conf
70+
71+
#
72+
# Suppress duplicate messages and report "message repeated n times"
73+
#
74+
$RepeatedMsgReduction on
75+
76+
###############
77+
#### RULES ####
78+
###############

dockers/docker-base-stretch/etc/supervisor/containercfgd.conf

-9
This file was deleted.

dockers/docker-base/Dockerfile.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ RUN apt-get -y install \
4949
rsyslog \
5050
less
5151

52+
COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"]
5253
COPY ["etc/rsyslog.d/*", "/etc/rsyslog.d/"]
5354
COPY ["root/.vimrc", "/root/.vimrc"]
5455

@@ -67,7 +68,6 @@ RUN mkdir -p /etc/supervisor/conf.d
6768
RUN mkdir -p /var/log/supervisor
6869
6970
COPY ["etc/supervisor/supervisord.conf", "/etc/supervisor/"]
70-
COPY ["etc/supervisor/containercfgd.conf", "/etc/supervisor/conf.d/"]
7171
7272
RUN apt-get -y purge \
7373
exim4 \

dockers/docker-base/etc/rsyslog.conf

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#
2+
# /etc/rsyslog.conf Configuration file for rsyslog.
3+
#
4+
# For more information see
5+
# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html
6+
7+
8+
#################
9+
#### MODULES ####
10+
#################
11+
12+
$ModLoad imuxsock # provides support for local system logging
13+
14+
#
15+
# Set a rate limit on messages from the container
16+
#
17+
$SystemLogRateLimitInterval 300
18+
$SystemLogRateLimitBurst 20000
19+
20+
#$ModLoad imklog # provides kernel logging support
21+
#$ModLoad immark # provides --MARK-- message capability
22+
23+
# provides UDP syslog reception
24+
#$ModLoad imudp
25+
#$UDPServerRun 514
26+
27+
# provides TCP syslog reception
28+
#$ModLoad imtcp
29+
#$InputTCPServerRun 514
30+
31+
32+
###########################
33+
#### GLOBAL DIRECTIVES ####
34+
###########################
35+
36+
set $.CONTAINER_NAME=getenv("CONTAINER_NAME");
37+
38+
# Set remote syslog server
39+
template (name="ForwardFormatInContainer" type="string" string="<%PRI%>%TIMESTAMP:::date-rfc3339% %HOSTNAME% %$.CONTAINER_NAME%#%syslogtag%%msg:::sp-if-no-1st-sp%%msg%")
40+
*.* action(type="omfwd" target=`echo $SYSLOG_TARGET_IP` port="514" protocol="udp" Template="ForwardFormatInContainer")
41+
42+
#
43+
# Use traditional timestamp format.
44+
# To enable high precision timestamps, comment out the following line.
45+
#
46+
#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
47+
48+
# Define a custom template
49+
$template SONiCFileFormat,"%TIMESTAMP%.%timestamp:::date-subseconds% %HOSTNAME% %syslogseverity-text:::uppercase% %$.CONTAINER_NAME%#%syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
50+
$ActionFileDefaultTemplate SONiCFileFormat
51+
52+
#
53+
# Set the default permissions for all log files.
54+
#
55+
$FileOwner root
56+
$FileGroup adm
57+
$FileCreateMode 0640
58+
$DirCreateMode 0755
59+
$Umask 0022
60+
61+
#
62+
# Where to place spool and state files
63+
#
64+
$WorkDirectory /var/spool/rsyslog
65+
66+
#
67+
# Include all config files in /etc/rsyslog.d/
68+
#
69+
$IncludeConfig /etc/rsyslog.d/*.conf
70+
71+
#
72+
# Suppress duplicate messages and report "message repeated n times"
73+
#
74+
$RepeatedMsgReduction on
75+
76+
###############
77+
#### RULES ####
78+
###############

0 commit comments

Comments
 (0)