And I found that the log messages shown on Graylog are duplicated. Sometimes only some of messages duplicate once/ twice(some duplicate 5 times) and sometimes messages are missing.
After checked the configurations on Graylog and rsyslog, I have no ideas for above case.
For the duplicate messages, id are different such as:
59d87baa-5f1e-11ec-80b7-005056a08a6d
59d2d655-5f1e-11ec-80b7-005056a08a6d
The logs are generated by python program around 100 messages per mintues.
There is only one index and I choose one stream to view the log.
I suspect this will be an interaction between Rsyslog.d and the log generated by the python program. Neither of these are Graylog components, and I’m no expert on Rsyslog.d, so perhaps someone else can illuminate on this.
Personally, I would look to swap use of Rsyslog.d to instead use Filebeats. It’s easier to set up and maintain than Rsyslog and more importantly, it keeps track of which messages Graylog has received - so if Graylog is stopped and then later resumed, no messages are dropped in the intervening period.
I have to completely agree with @tellistone suggestion about FileBeat. When I first started out I want to use a service that was native to Linux (Rsyslog) but later I found out that is was more difficult to configure Rsyslog as my environment grew or if we needed to improve on how logs were sent to Graylog.
That being said. Have you tried to only use one of these?
On one of my CentOS 7.9 Lab servers I’m just running this configuration.
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
$ModLoad imjournal # provides access to the systemd journal
$ModLoad imudp
$WorkDirectory /var/lib/rsyslog
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
$IncludeConfig /etc/rsyslog.d/*.conf
$OmitLocalLogging on
$IMJournalStateFile imjournal.state
kern.debug /var/log/firewall.log
*.info;mail.none;authpriv.none;cron.none /var/log/messages
authpriv.* /var/log/secure
mail.* -/var/log/maillog
cron.* /var/log/cron
*.emerg :omusrmsg:*
uucp,news.crit /var/log/spooler
local7.* /var/log/boot.log
*.*@8.8.8.8:5140 <--- UDP connection
OR
*.*@@8.8.8.8:5140 <--- TCP connection
Here are some sites I have used in the past to help me out.