在我的用例中,我有一个生成大量日志的服务,除了loggly(第三方ELK作为服务)之外,还必须将日志写入文件中。
该服务配置为将json日志写入端口515
我看到一个问题,一旦服务运行了一段时间,service_log.jsonl
中的日志就会以越来越高的速度落后。我怀疑这是由于direct_service_json
和push_loggly_service
的操作队列以某种方式耦合
[理想情况下,我想完全解耦direct_service_json
和push_loggly_service
,以便push_loggly_service
编写器可以花很多时间,只要direct_service_json
保持服务日志上的最新状态,就可以将日志推送到Loggly。 >
执行此操作的最佳方法是什么?我提供了我正在使用的配置文件-使用此配置,service_log.jsonl
中的日志在30分钟左右的时间内开始滞后]
module(load="omhttp") module(load="mmjsonparse") module(load="imudp") template(name="json_logs" type="list") { constant(value="{") property(name="hostname" outname="hostname" format="jsonfr") constant(value=",") property(name="timereported" outname="timestamp" format="jsonfr" dateFormat="rfc3339") constant(value=",") property(name="programname" outname="proc" format="jsonfr") constant(value=",") property(name="syslogpriority-text" outname="level" format="jsonfr") constant(value=",") property(name="$!all-json" position.from="2") } template(name="simple" type="list") { property(name="syslogtag") property(name="msg") constant(value="\n") } # Write messages to /var/log/service_logs.jsonl ruleset(name="direct_service_json" queue.Type="LinkedList") { action(type="omfile" file="/var/log/service_logs.jsonl" template="simple") } # Send messages to Loggly using the json_logs template. # Using two consumers to handle insane log volume # Consumers are capped at 4, rsyslog spawns workers when action is backlogged at 100 ruleset(name="push_loggly_service" queue.Type="LinkedList" queue.WorkerThreads="4" queue.workerThreadMinimumMessages="100"){ action(type="mmjsonparse" cookie="") action(type="omhttp" server="logs-01.loggly.com" errorfile="/var/log/rsyslog.error.log" restpath="inputs/SECRET_TOKEN/tag/rsyslog" retry="on" useHttps="on" template="json_logs" ) } input(type="imudp" port="515" name="json-input") # Hack - attempt to decouple the file writer from the loggly writer if $inputname == "json-input" then { call direct_service_json } if $inputname == "json-input" then { call push_loggly_service }
在我的用例中,我有一个生成大量日志的服务,除了loggly之外,还必须将日志写入文件(第三方ELK作为服务)。该服务配置为将json日志写入到...
根据来自rsyslog维护者之一的建议,我成功地将主队列与操作队列解耦了。
我使用impstats
模块来监视队列,以发现瓶颈。