部署filebeat采集nginx


部署filebeat采集nginx 其余应用请参考

1.下载并安装 Filebeat

第一次使用 Filebeat?请参阅入门指南。https://www.elastic.co/guide/en/beats/filebeat/7.4/filebeat-getting-started.html
curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.4.2-x86_64.rpm
sudo rpm -vi filebeat-7.4.2-x86_64.rpm

2.编辑配置

修改/etc/filebeat/filebeat.yml设置连接信息:

output.elasticsearch:
  hosts: [""]
  username: "elastic"
  password: ""
setup.kibana:
  host: ""
哪里是elastic用户的密码,是Elasticsearch的URL,是Kibana的URL。
本次部署并未使用x-pack安全认证,username&password 可直接注释。以下为示例
setup.kibana:
    host: "ADDR:PORT"
output.elasticsearch:
    hosts: ["ADDR:PORT"]

3.启用和配置 nginx 模块

sudo filebeat modules enable nginx
修改/etc/filebeat/modules.d/nginx.yml文件中的设置。  以下为示例
- module: nginx
  # Access logs
  access:
    enabled: true

    # Set custom paths for the log files. If left empty,
    # Filebeat will choose the paths depending on your OS.
    var.paths:  ["/usr/local/nginx/logs/access.log*"]

  # Error logs
  error:
    enabled: true

    # Set custom paths for the log files. If left empty,
    # Filebeat will choose the paths depending on your OS.
    #var.paths:
    var.paths:  ["/usr/local/nginx/logs/error.log*"]

4.启动 Filebeat

setup命令加载 Kibana 仪表板。如果已设置仪表板,请省略此命令。

sudo filebeat setup
sudo service filebeat start
sudo systemctl start filebeat

···

即查看filebeat状态是否正常,无误后,kibana找寻对应索引即可。

文章作者: 一抹忘忧
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 一抹忘忧 !
  目录