FileBeat+Mycat

Kibana+ElasticSearch 已经安装完毕
FileBeat配置详解(感谢作者分享):https://www.cnblogs.com/wshenjin/p/13652361.html
检测目标:监测Mycat日志,包括请求的IP,执行的SQL,以及Route路由地址
1、开启Mycat的Log Debug

进入Mycat安装目录conf

vim log4j2.xml
   <asyncRoot level="debug" includeLocation="true">
## 改成Debug
  • Mycat.log
    在这里插入图片描述
1、FileBeat RPM安装
## curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.9.2-x86_64.rpm
## sudo rpm -vi filebeat-7.9.2-x86_64.rpm
  • vim /etc/filebeat/filebeat.yml
# ============================== Filebeat inputs ===============================

filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /home/mycatserver/mycat/logs/mycat.log #Mycat的日志
  # 
 multiline.pattern: '^\d{4}\-\d{2}\-\d{2}\s\d{2}:\d{2}:\d{2}' ## 合并多行正则
 multiline.negate: true ## 是否合并到上一行
 multiline.match: after ## 追加到上一行的头还是未


# ======================= Elasticsearch template setting =======================

setup.template.settings:
  index.number_of_shards: 1
  #index.codec: best_compression
  #_source.enabled: false
setup.template.name: "mycat"
setup.template.pattern: "mycat-*"

setup.kibana:
  host: "192.168.1.111:5601"

# ================================== Outputs ===================================

# Configure what output to use when sending the data collected by the beat.

# ---------------------------- Elasticsearch Output ----------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["192.168.1.111:9200"]
  index: "mycat_log"    
  # index: "mycat_log_%{+yyyy.MM.dd}"  #按天创建Index,需要的可以放开
  # Protocol - either `http` (default) or `https`.
  #protocol: "https"

  # Authentication credentials - either API key or username/password.
  #api_key: "id:api_key"
  #username: "elastic"
  #password: "changeme"

# ================================= Processors =================================
processors:
 - add_host_metadata:
      when.not.contains.tags: forwarded
 - add_cloud_metadata: ~
 - add_docker_metadata: ~
 - add_kubernetes_metadata: ~
启动:sudo filebeat -e -c filebeat.yml  -d "publish"
  • 注意:filebeat6配置index需要添加setup对应项,不然启动会报错
setup.template.name: "mycat"        #顶格,和output对齐
setup.template.pattern: "mycat-*"   #顶格,和output对齐
output.elasticsearch:
  hosts: ["192.168.1.111:9200"]
  index: "mycat_log"     #和hosts对齐

问题:

启动之后发现,index没用,根本没有根据配置创建index,而是filebeat-xxx,
ElasticStack从2019年1月29日的6.6.0版本的开始,引入了索引生命周期管理的功能,新版本的Filebeat则默认的配置开启了ILM,导致索引的命名规则被ILM策略控制。本文用的filebeat-7.9.2-x86_64.rpm

  • 修改:
# filebeat 配置关闭 ILM 即可解决Index Pattern不生效的问题
	setup.ilm.enabled: false
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值