We're using filebeat to forward logs to a redis server, then they're processed with logstash and indexed by elasticsearch
One of our customers complains, that filebeat needs more resources than the process that writes the logs
In his opinion there's something wrong with it, blames the regular expression (his old log forwarder, just needs about 1% CPU - just forwards plain text messages via UDP, which is a total different scenario, however target is, to minimise the performance impact the new log pipeline). so we did a few tests to check it.
so we took a log file, written while lots of traffic (501Mbyte, 1944137 events in 371s, 5240 events / second), and forwarded it with filebeat to our redis queue. We limited the cpus via max_procs to 1.
Filebeat (6.4, running under CentOs, Xeon(R) CPU E5-2640) took about 93s (21k/sec) to forward the logs to REDIS, using 100% of 1 cpu. so we estimated, it would use about 29% of 1 cpu when it would submit the logs while being written.
We then did several tests e.g.
- without regexp it took 117s (38k /sec, but it since it had to submit much more messages, this is not compareable )
- using plain codec 74s(26k/sec)
- using plain codec, writing to console 63s(31k/s)
We think the CPU usage of filebeat is normal, or did we overlook a magic switch to lower it significantly?
Here's our filebeat.yml for the default test:
- input_type: log
paths:
- "${path.home}/data/ourservice/*.log"
fields:
type: ourtype
service: ourservice
hostname: hostxy
ipV4: 127.0.0.1
multiline.pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}[T][[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}'
multiline.negate: true
multiline.match: after
tail_files: false
close_eof: true
#------------------------------- Redis output ----------------------------------
output.redis:
# Boolean flag to enable or disable the output module.
enabled: true
hosts: ["127.0.0.2:6379"]
# default logs.
key: logs
#the priority lane for correlation records
keys:
- key: correlation
when.contains:
message: "H_trnsp"
Thank you so much for your feedback, i could also offer a cpu profile for the default test, if it would be useful.