rsyslog是syslog的升级版,是一个日志管理服务,可以作为客户端与服务端进行启动,收集服务器上的任意日志。rsyslog经常需要配合logstash将日志推送到ES。然而logstash需要java服务,需要额外的安装。通过查询rsyslog,发现omelasticsearch插件,使用ES的http api,可以直接将日志发送到ES。
2.安装服务器:CentOS Linux release 7.9.2009 (Core)
centos 默认安装了rsyslog,所以不需要安装主体。直接安装omelasticsearch插件:
3.配置rsyslogyum install rsyslog-elasticsearch
/etc/rsyslog.conf
//加载模块
module(load="omelasticsearch")
//配置log模版
template(name="pot"
type="list"
option.json="on") {
constant(value="{")
constant(value=""timestamp":"") property(name="timereported" dateFormat="rfc3339")
constant(value="","message":"") property(name="msg")
constant(value="","host":"") property(name="hostname")
constant(value="","severity":"") property(name="syslogseverity-text")
constant(value="","facility":"") property(name="syslogfacility-text")
constant(value="","syslogtag":"") property(name="syslogtag")
constant(value=""}")
}
//发送日志配置
action(type="omelasticsearch"
file = "/var/log/pot.log" //发送的文件
server="127.0.0.1"
serverport="9200"
template="pot"
searchIndex="pot"
bulkmode="on"
maxbytes="100m"
queue.type="linkedlist"
queue.size="5000"
queue.dequeuebatchsize="300"
action.resumeretrycount="-1")



