栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Filebeat入门及使用-5 读取nginx日志,写入ES

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Filebeat入门及使用-5 读取nginx日志,写入ES

1 安装nginx,并找到nginx的日志目录,步骤3要使用

2 配置Filebeat的module,在Filebeat中,有大量的module,如mysql,kafka,redis,nginx等,可以简化我们的配置,方便使用。

查看Filebeat支持模块
命令:./filebeat modules list

启动Nginx模块
启动命令:./filebeat modules enable nginx
禁用命令:./filebeat modules disable nginx

3 配置modules.d/nginx.yml文件,指定access.log 和 error.log 的地址

- module: nginx
  # Access logs
  access:
    enabled: true
    var.paths: ["/usr/local/nginx/logs/access.log*"]

  # Error logs
  error:
    enabled: true
    var.paths: ["/usr/local/nginx/logs/error.log*"]

4 新建读取nginx的配置文件 a_nginx.yml

# 输入
filebeat.inputs:

# 增加标签
tags: ["nginx10"]

# 指定索引的分区数
setup.template.settings:
  index.number_of_shards: 1

filebeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false

# 输出到指定ES的配置
output.elasticsearch:
  hosts: ["127.0.0.1:9200"]

5 运行 ./filebeat -e -c a_nginx.yml

6 测试,访问nginx主页后,ES中效果如下

另外,有些低版本的ES,可能会报出以下错误,如下,需要安装相关的jar到ES目录中,方法到网上找.
Elasticsearch nodes:
sudo bin/elasticsearch-plugin install ingest-user-agent
sudo bin/elasticsearch-plugin install ingest-geoip

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/757934.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号