进入filebeat目录,增加nginxlog.yml配置文件,配置如下,主要修改paths下的log目录地址以及设置output为logstash的IP端口地址。本文地址:http://www.04007.cn/article/834.html,未经许可,不得转载.
user@u007:/opt/filebeat/filebeat-7.7.1-linux-x86_64$ cat nginxlog.yml filebeat.inputs: - type: log enabled: true paths: - /opt/nginxlog/*.log filebeat.config.modules: path: ${path.config}/modules.d/*.yml reload.enabled: true setup.template.settings: index.number_of_shards: 6 output.logstash: hosts: ["10.21.45.25:5044"] #启动filebeat同时使用public输出日志 user@u007:/opt/filebeat/filebeat-7.7.1-linux-x86_64$ ./filebeat -e -c nginxlog.yml -d "publish"
进入logstash目录,增加config下nginxlog.conf配置文件,设置数据input来源的beats端口,以及output设置为elasticsearch的hosts列表,指定index名称。本文地址:http://www.04007.cn/article/834.html,未经许可,不得转载.
user@u007:/opt/logstash/logstash-7.7.1$ cat config/nginxlog.conf # Sample Logstash configuration for creating a simple # Beats -> Logstash -> Elasticsearch pipeline. input { beats { port => 5044 } } output { elasticsearch { hosts => ["http://192.168.11.11:9200", "http://192.168.11.12:9200" ,"http://192.168.11.13:9200"] index => "nginxlog-%{+YYYY.MM.dd}" } stdout { codec=> rubydebug } } #启动logstash user@u007:/opt/logstash/logstash-7.7.1$ bin/logstash -f config/nginxlog.conf
启动filebeat和logstash之后,/opt/nginxlog/*.log类日志文件的数据就会从filebeat->logstash->elasticsearch进入索引库。nginxlog-%{+YYYY.MM.dd},示例如图:本文地址:http://www.04007.cn/article/834.html,未经许可,不得转载.
本文地址:http://www.04007.cn/article/834.html,未经许可,不得转载.
本文地址:http://www.04007.cn/article/834.html 未经许可,不得转载. 手机访问本页请扫描右下方二维码.
![]() |
![]() |
手机扫码直接打开本页面 |