mysql - Logstash Grok 过滤 mysql 慢查询
问题描述
我正在尝试使用 grok 过滤 mysql 慢查询。我需要得到
- 数据库名称
- 用户
- 知识产权
- 查询时间
- 命令
来人帮帮我?
# User@Host: tysa6775_ua_data[tysa6775_ua_data] @ localhost [] Id: 360
# Query_time: 1.627188 Lock_time: 0.000246 Rows_sent: 5566 Rows_examined: 459414
use tysa6775_au_data1;
SET timestamp=1541421036;
select * from table_rating where id_product=1009 order by ngaytao desc;
# User@Host: tysa6775_ua_data[tysa6775_ua_data] @ localhost [] Id: 360
# Query_time: 0.000569 Lock_time: 0.000308 Rows_sent: 0 Rows_examined: 3
SET timestamp=1541421036;
select * from table_hoidap where id_product=1009 order by ngaytao desc;
# User@Host: tysa6775_ua_data[tysa6775_ua_data] @ localhost [] Id: 360
# Query_time: 0.000349 Lock_time: 0.000208 Rows_sent: 0 Rows_examined: 28
SET timestamp=1541421036;
select * from table_product_like where id_product='1009' and ip_nguoilike='5.188.210.8' order by stt,id desc;
解决方案
由于您尝试访问的数据分布在日志文件中的多行中,因此您需要使用多行编解码器,它将从这些行中生成单个事件。
推荐阅读
- wordpress - 我们可以在另一个自定义帖子下添加自定义帖子吗
- jquery - 计算按钮出现的次数
- dataframe - 如何去除姓名首字母中的点和空格
- git - 当我尝试在 VS-Code 中重新设置 git 显示 rebase 2/165 时,这是什么意思以及如何重置它?
- java - 如何使用 Math.random() 生成不重复的随机数?
- javascript - 刷新长寿命访问令牌端点是否在 2021 年工作?
- javascript - 工厂函数方法不更新变量
- r - 根据R中的ID将一列随机分成两组
- date - 将浮点值转换为月和日
- javascript - 在表中显示反应中相同项目的值