前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >Logstash 处理 Mysql Slow Log5

Logstash 处理 Mysql Slow Log5

作者头像
franket
发布2022-01-20 11:34:26
发布2022-01-20 11:34:26
19500
代码可运行
举报
文章被收录于专栏:技术杂记技术杂记
运行总次数:0
代码可运行

filter 是整个mysql 日志处理的核心部分,就是通过它来抓取信息赋给各个filed

Item

Comment

filter {

框定处理逻辑的定义范围

grok {

定义了一个过滤器,使用 grok 插件来解析文本,和抓取信息,用于文本结构化

match => ["message",".*"]

用来match哈希 {"message" => ".*patten.*"},然后把正则捕获的值作为事件日志的filed

date {

定义了一个过滤器,使用 date 插件来从fileds中解析出时间,然后把获取的时间值作为此次事件日志的时间戳

match => [ "timestamp", "UNIX" ]

取用 timestamp 中的时间作为事件日志时间戳,模式匹配为UNIX

#remove_field => [ "timestamp" ]

一般而言,日志会有一个自己的时间戳 @timestamp ,这是logstash或 beats看到日志时的时间点,但是上一步已经将从日志捕获的时间赋给了 @timestamp ,所以 timestamp 就是一份冗余的信息,可以使用 remove_field 方法来删掉这个字段,但我选择保留

The date filter is especially important for sorting events and for backfilling old data. If you don’t get the date correct in your event, then searching for them later will likely sort out of order. In the absence of this filter, logstash will choose a timestamp based on the first time it sees the event (at input time), if the timestamp is not already set in the event. For example, with file input, the timestamp is set to the time of each read.


output

代码语言:javascript
代码运行次数:0
运行
复制
output {
  elasticsearch { 
  	hosts => ["localhost:9200"] 
        index=>"mysql-slow-log-%{+YYYY.MM.dd}"
	}
  stdout { codec => rubydebug }
}

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • output
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档