Ubuntu下整合Filebeat和Logstash,读取nginx的日志

本文介绍了如何在Ubuntu系统中配置Filebeat和Logstash,以读取并处理Nginx的日志。首先,在Logstash目录创建并编辑配置文件,然后测试配置文件的正确性。接着,配置Filebeat并创建相应的配置文件,启动Filebeat。最后,通过访问Nginx服务验证配置成功,日志信息将在控制台输出。
摘要由CSDN通过智能技术生成

1.配置Logstash:在logstash目录下新建配置文件并编辑。

命令:sudo vi test-pipeline.conf

input {
    beats {
        port => "5044"
    }
}
output {
    stdout { codec => rubydebug }
}

2.测试配置文件:

测试配置文件是否正确

# 启动 --config.test_and_exit 

 

# 正式启动 --config.reload.automatic 热加载配置文件,修改配置文件后无需重新启动。

 

3.配置filebeat:在filebeat目录下新建配置文件并编辑。

命令:sudo vi test-nginx.yml

filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /var/log/nginx/access.log
  tags: ["log"]
  fields:
    from: nginx
  fields_under_root: false
output.logstash:
  hosts: ["10.0.2.15:5044"]


4.启动filebeat

命令:sudo ./filebeat -e -c test-nginx.yml

如下图:证明与logstash成功建立连接。

 

5.访问nginx

此时可以访问nginx服务(之前已经通过service nginx start启动nginx服务)。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值