• Filebeat收集单个日志

1.配置收集日志到文件

filebeat.inputs:
- type: logenable: truepaths:# linux系统#- /var/log/nginx/access.log# windows系统- C:\Users\Administrator\logs\nacos\config.log
output.file:path: "/tmp"filename: "filebeat.log"

2.配置收集日志到ES

filebeat.inputs:
- type: logenable: truepaths:- /var/log/nginx/access.log
output.elasticsearch:hosts: ["10.0.0.51:9200"]

3.配置收集日志为json格式

1)配置

#由于收集日志内容还是写到了message,没有办法作图
[root@web01 ~]# vim /etc/filebeat/filebeat.yml
filebeat.inputs:
- type: logenable: truepaths:- /var/log/nginx/access.logjson.keys_under_root: truejson.overwrite_keys: true
output.elasticsearch:hosts: ["10.0.0.51:9200"]# keys_under_root
默认情况下,解码后的JSON放在输出文档中的“json”键下。 如果启用此设置,则会将键复制到输出文档的顶层。 默认值是false。# overwrite_keys
如果启用了keys_under_root和此设置,则来自解码的JSON对象的值会覆盖Filebeat通常添加的字段(类型,源,偏移量等)以防冲突。

2)修改Nginx日志格式

#filebeat只支持某种json格式写法
[root@web01 ~]# vim /etc/nginx/nginx.conf
... ...log_format log_json '{ "time_local": "$time_local", ''"remote_addr": "$remote_addr", ''"referer": "$http_referer", ''"request": "$request", ''"status": $status, ''"bytes": $body_bytes_sent, ''"agent": "$http_user_agent", ''"x_forwarded": "$http_x_forwarded_for", ''"up_addr": "$upstream_addr",''"up_host": "$upstream_http_host",''"upstream_time": "$upstream_response_time",''"request_time": "$request_time" }';... ...

3)重启

1.重启Nginx
2.重启Filebeat
3.删除原来的索引
4.清空Nginx日志

4.收集日志配置指定索引名称

1)配置

[root@web01 ~]# vim /etc/filebeat/filebeat.yml
filebeat.inputs:
- type: logenable: truepaths:- /var/log/nginx/access.logjson.keys_under_root: truejson.overwrite_keys: true
output.elasticsearch:hosts: ["10.0.0.51:9200"]index: "nginx_log_%{+YYYY-MM-dd}"
setup.template.enabled: false
setup.template.name: "nginx"
setup.template.pattern: "nginx-*"#模板的名称
setup.template.name: "nginx"
#模板模式,通配符-*用于匹配每日索引
setup.template.pattern: "nginx-*"
#是否覆盖现有模板
setup.template.overwrite: false
#禁用模板加载
setup.template.enabled: false

2)指定分片数

[root@web01 ~]# vim /etc/filebeat/filebeat.yml.bak
setup.template.settings:index.number_of_shards: 3

5.收集日志到redis

1)配置

# 这里指定redis的密码为123[root@web01 ~]# vim /etc/filebeat/filebeat.yml
filebeat.inputs:
- type: logenable: truepaths:- /var/log/nginx/access.logjson.keys_under_root: truejson.overwrite_keys: true
output.redis:hosts: ["172.16.1.51"]port: "6379"key: "nginx_access"password: 123db: 0

2)查看redis

#访问Nginx页面后,查看redis是否有数据
127.0.0.1:6379> keys *
1) "nginx_access"
127.0.0.1:6379> TYPE nginx_access
list
127.0.0.1:6379> LLEN nginx_access
(integer) 8
127.0.0.1:6379> LRANGE nginx_access 0 -1

6.使用logstash将redis数据取出到ES

# 建议redis的数据通过logstash进行取出,不要使用filebeat,因为logstash可以对具体索引拿取数据,而不是像filebeat只能指定host。
[root@web01 conf.d]# vim redis_to_es.conf
input {redis {host => "172.16.1.51"port => "6379"db => "0"data_type => "list"key => "nginx_access"password => "123"}
}
output {elasticsearch {hosts => ["10.0.0.51:9200"]index => "nginx_access_%{+YYYY-MM-dd}"}
}

7.filebeat收集日志到logstash

1)配置收集日志到logstash

[root@web01 ~]# vim /etc/filebeat/filebeat.yml
filebeat.inputs:
- type: logenable: truepaths:- /var/log/nginx/access.logjson.keys_under_root: truejson.overwrite_keys: true
output.logstash:hosts: ["172.16.1.52:3456"]#如果启动失败,查看日志,应该是172.16.1.52服务器的3456端口没有启动,需要先启动52的logstash

2)配置logstash收集日志到ES

[root@db02 ~]# vim /etc/logstash/conf.d/filebeat_logstash_es.conf
input {beats {port => 3456codec => "json"}
}
output {elasticsearch {hosts => ["10.0.0.51:9200"]index => "nginx_filebeat_logstash_es"}
}
  • Filebeat收集多日志

1.收集多日志到ES

1)方式一

[root@web01 ~]# vim /etc/filebeat/filebeat.yml
filebeat.inputs:
- type: logenable: truepaths:- /var/log/nginx/access.logjson.keys_under_root: truejson.overwrite_keys: true
- type: logenable: truepaths:- /var/log/messagesoutput.elasticsearch:hosts: ["10.0.0.51:9200"]indices:- index: "nginx_%{+YYYY-MM-dd}"when.contains:source: "/var/log/nginx/access.log"- index: "message_%{+YYYY-MM-dd}"when.contains:source: "/var/log/messages"
setup.template.enabled: false
setup.template.name: "nginx"
setup.template.pattern: "nginx-*"

2)方式二

[root@web01 ~]# vim /etc/filebeat/filebeat.ymlfilebeat.inputs:
- type: logenable: truepaths:- /var/log/nginx/access.logjson.keys_under_root: truejson.overwrite_keys: truetags: ["nginx"]- type: logenable: truepaths:- /var/log/messagestags: ["messages"]output.elasticsearch:hosts: ["10.0.0.51:9200"]indices:- index: "nginx_%{+YYYY-MM-dd}"when.contains:tags: "nginx"- index: "message_%{+YYYY-MM-dd}"when.contains:tags: "messages"
setup.template.enabled: false
setup.template.name: "nginx"
setup.template.pattern: "nginx-*"

三、filebeat收集java报错

1)配置

[root@web01 ~]# vim /etc/filebeat/filebeat.yml
filebeat.inputs:
- type: logenable: truepaths:- /var/log/nginx/access.logmultiline.pattern: '^\['multiline.negate: truemultiline.match: afteroutput.elasticsearch:hosts: ["10.0.0.51:9200"]index: "tomca_error_%{+YYYY-MM-dd}"
setup.template.enabled: false
setup.template.name: "nginx"
setup.template.pattern: "nginx-*"

2)导入错误日志查看

Filebeat日志收集相关推荐

  1. Filebeat日志收集器

    一.Filebeat 日志收集器 1.1 Filebeat简介 Filebeat是用于"转发"和"集中日志数据"的"轻量型数据采集器",用g ...

  2. 搭建elk+logstash+kafka+filebeat日志收集平台

    文章目录 前言 组件介绍 原理图 环境介绍 安装 日志收集与展示 前言 在日常的运维过程中,对系统日志和业务日志的处理比较重要,对于以后的数据分析.排查异常问题有很重的作用.今天就分享一个自己基于ka ...

  3. 部署ELK+Kafka+Filebeat日志收集分析系统

    ELK+Kafka+Filebeat日志系统 文章目录 ELK+Kafka+Filebeat日志系统 1.环境规划 2.部署elasticsearch集群 2.1.配置es-1节点 2.2.配置es- ...

  4. ELK (一)部署ELK+Filebeat日志收集分析系统

    说明:此安装流程只适用于8.0.0以下的版本 1. ElasticSearch 部署 1.1 下载ElasticSearch的wget指令: wget https://artifacts.elasti ...

  5. filebeat 收集json格式_集群日志收集架构ELK

    欢迎关注头条号:老顾聊技术 精品原创技术分享,知识的组装工 前言 前几篇我们介绍了项目中如何使用logback组件记录系统的日志情况:现在我们的系统都是分布式的,集群化的,那就代表着我们的应用会分布在 ...

  6. ELK之日志收集filebeat,并对nginx,tomcat access日志JSON格式化

    2019独角兽企业重金招聘Python工程师标准>>> 一:ELK日志收集器组件filebeat下载 官方下载地址:https://www.elastic.co/downloads/ ...

  7. filebeat+logstash收集错误日志发送邮件提醒

    filebeat+logstash收集错误日志发送邮件提醒 典型ELK应用架构 因为只收集错误日志并且数据量并不是非常大所以简化流程 使用filebeat+logstash发送异常日志 软件 版本 说 ...

  8. 基于filebeat + logstash的日志收集方案

    日志收集是一个很普遍的需求,各个服务的log日志,打点日志都需要收集起来做离线etl或实时分析.日志收集工具也有很多开源的可供选择,flume,  logstash, filebeat等等.  目前3 ...

  9. EFK(Elasticsearch+Filebeat+Kibana)日志收集系统

    EFK简介 Elasticsearch 是一个实时的.分布式的可扩展的搜索引擎,允许进行全文.结构化搜索,它通常用于索引和搜索大量日志数据,也可用于搜索许多不同类型的文档. Beats 是数据采集的得 ...

  10. ELK+Filebeat+Kafka+ZooKeeper+Grafana大数据日志收集与分析平台

    一.ELK与EFK架构 日志主要包括系统日志.应用程序日志和安全日志.系统运维和开发人员可以通过日志了解服务器软硬件信息.检查配置过程中的错误及错误发生的原因.经常分析日志可以了解服务器的负荷,性能安 ...

最新文章

  1. java常见面试题及答案 11-20(JVM篇)
  2. linux培训描述,【linux培训班】关于linux系统记录和描述进程的分析
  3. Linq使用Group By 1
  4. 评审恩仇录——IDE也能做代码评审?
  5. 一.JavaScript基础
  6. npm修改默认安装路径和数据源
  7. python 公司年会抽奖_用Python做个年会抽奖小程序吧
  8. 萤石云设备下线是什么导致的_什么原因导致化工设备腐蚀?腐蚀防护措施有哪些?...
  9. 学习一下戴戒指的含义[转]
  10. 安全测试===sqlmap(壹)转载
  11. 两个相同矩形脉冲卷积_两个矩形脉冲的卷积
  12. remote: 认证失败,请确认您输入了正确的账号密码。 fatal: Authentication failed
  13. 文件io(二)--unix环境高级编程笔记
  14. coolfire文章之一
  15. 浅析数据中心交换机芯片,中国自主可控国产化交换机已是历史必然
  16. win10设置保护色
  17. 呼叫中心点击拨打接口升级代码
  18. 细说自动筛选和高级筛选通过VBA快速文本筛选
  19. php的implode函数的作用是,PHP函数implode介绍
  20. 网上作业批改系统的设计与实现(JSP,MySQL)

热门文章

  1. nwjs macOS打包成dmg
  2. 妈耶,摆脱机器音,二次宅的歌姬女友彻底活了
  3. 系统稳定性建设实践总结
  4. IPython安装使用详解
  5. STVD+Cosmic搭建STM8开发环境
  6. 图像处理的边缘和纹理的区别
  7. IntelliJ IDEA插件-翻译插件
  8. 站在2018看单片机和嵌入式芯片方案选型和发展趋势
  9. 风尚云网学习-css实现文字超出隐藏为省略号...
  10. ffmpeg 音频转amr