步骤简单记录。
java安装略
logstash5.4 解压版,安装略
前提条件:日志为json格式。
这里手动将nginx的日志拼为json。
input { file { type => "nginx_log" path => "/var/log/nginx/access.log" } } # 将message字段的数据(json格式) "导入",供下面if判断调用。 filter { json { source => "message" } } output { # http 模块会将数据提交到指定url if [loglevel] == "error" { http { http_method => "post" url => "https://www.rootop.org/xxx.php" } } elasticsearch { hosts => "192.168.10.71" index => "nginx-access-%{+YYYY.MM.dd}" } stdout { codec => rubydebug } }
path => “/var/log/nginx/access.log” 支持通配符,如*.log ,实现一天一个日志文件,并可以持续采集日志
路径中也可以带通配符
原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/4228.html