logstash 解析mysql slow log

原创 2016年08月30日 20:24:35
# User@Host: zjzc_app[zjzc_app] @  [10.252.148.16xx]  Id: 6043127
# Query_time: 2.581184  Lock_time: 0.000336 Rows_sent: 6  Rows_examined: 6331310
SET timestamp=1472536079;
select temp.* from ( SELECT 
		    *
		FROM
		    (SELECT 
		        c.sn,
	            c.userNick,
	            c.mobilePhone,
	            date_format(c.registerTime,'%Y/%m/%d') registerTime,
	            cp.personName,
	            cp.personCardNo,
	            cp.gender,
	            cp.personAuthStatus,
	            asm.clientManagerSn,
	            (select personName from ClientPersonalInfo where clientSn = asm.clientManagerSn) as clientManagerName,
	            IF(1600=asm.clientManagerSn or 1600 IS null, 1, 0) as isMyself,
	            IFNULL(cei.policyAreaSn,IF( LENGTH(SUBSTRING_INDEX(cm.`governAreas`,';',2))=LENGTH(cm.`governAreas`),SUBSTRING_INDEX(cm.`governAreas`,';',1),NULL )) policyAreaSn,
	            area.areaName as policyAreaName,
			    (SELECT IFNULL(SUM(capitalBalance), 0) + IFNULL(SUM(yieldBalance), 0)
				FROM view_client_invest_summary 
				WHERE status =2 AND clientSn=c.`sn` AND DATEDIFF(settlementDate,CURDATE())   <=7   
				AND DATEDIFF(settlementDate,CURDATE())   >=0   ) investBalance,
			    (SELECT IFNULL(SUM(capitalBalance), 0) + IFNULL(SUM(yieldBalance), 0)
				FROM view_client_invest_summary pr
				WHERE pr.clientSn = c.sn AND pr.status = 2 ) unclearedBalance,
			    (SELECT IFNULL(SUM(capitalBalance), 0) + cai.availableBalance + cai.frozenWithDraw +tra.availableBalance
				FROM view_client_invest_summary
				WHERE clientSn = c.sn AND status in(1,2)) totalBalance,
			    (cai.frozenWithDraw + cai.frozenPay) frozenBalance,(cai.availableBalance+tra.availableBalance) availableBalance
		    FROM
		        Client c 
		        LEFT JOIN ClientExtraInfo cei on c.sn=cei.clientSn 
		        LEFT JOIN Area area on cei.policyAreaSn=area.sn
		        LEFT JOIN AssignClientManager asm ON asm.clientSn=c.sn
		        LEFT JOIN ClientManager cm on cm.sn = asm.clientManagerSn
		        LEFT JOIN TransferClientAssetInfo tra on c.sn=tra.clientSn, 
		        ClientPersonalInfo cp, ClientAssetInfo cai
		    WHERE
		        c.sn = cp.clientSn AND asm.status='1'
		            AND c.sn = cai.clientSn
		             
		       		 
		       			AND exists (select * from ClientInvestOrder where clientSn = c.sn and status =3)
		       		  
		       		  
		            AND c.sn IN (SELECT 
		                asm.clientSn
		            FROM
		                AssignClientManager asm
		            WHERE
		                asm.clientManagerSn IN 
		                 (  
                       		 1600
                		 ) 
                		 
                		AND asm.status='1')		
		       ) t
		     
		ORDER BY
		 
		t.clientManagerSn desc,t.sn desc ) temp   limit 10,10;
# Time: 160830 14:22:27


(?m)\s*# User@Host:\s+\S+\[%{USER:user}\]\s+@\s+\[%{IP:clientip}\]\s+(?<id>(\S+\s+)*\S+)\s*#\s+Query_time:\s+%{NUMBER:Query_time}\s+Lock_time: %{NUMBER:lock_time}\s+Rows_sent: %{NUMBER:rows_sent}\s+Rows_examined: %{NUMBER:rows_examined}\s*
SET\s+timestamp=%{NUMBER:timestamp};\s*(?<query>(\S+\s+).*)\s*#\s+Time:\s+.*

{
  "user": [
    [
      "zjzc_app"
    ]
  ],
  "clientip": [
    [
      "10.252.148.164"
    ]
  ],
  "id": [
    [
      "Id: 6043127"
    ]
  ],
  "Query_time": [
    [
      "2.581184"
    ]
  ],
  "lock_time": [
    [
      "0.000336"
    ]
  ],
  "rows_sent": [
    [
      "6"
    ]
  ],
  "rows_examined": [
    [
      "6331310"
    ]
  ],
  "timestamp": [
    [
      "1472536079"
    ]
  ],
  "query": [
    [
      "select temp.* from ( SELECT \n\t\t    *\n\t\tFROM\n\t\t    (SELECT \n\t\t        c.sn,\n\t            c.userNick,\n\t            c.mobilePhone,\n\t            date_format(c.registerTime,'%Y/%m/%d') registerTime,\n\t            cp.personName,\n\t            cp.personCardNo,\n\t            cp.gender,\n\t            cp.personAuthStatus,\n\t            asm.clientManagerSn,\n\t            (select personName from ClientPersonalInfo where clientSn = asm.clientManagerSn) as clientManagerName,\n\t            IF(1600=asm.clientManagerSn or 1600 IS null, 1, 0) as isMyself,\n\t            IFNULL(cei.policyAreaSn,IF( LENGTH(SUBSTRING_INDEX(cm.`governAreas`,';',2))=LENGTH(cm.`governAreas`),SUBSTRING_INDEX(cm.`governAreas`,';',1),NULL )) policyAreaSn,\n\t            area.areaName as policyAreaName,\n\t\t\t    (SELECT IFNULL(SUM(capitalBalance), 0) + IFNULL(SUM(yieldBalance), 0)\n\t\t\t\tFROM view_client_invest_summary \n\t\t\t\tWHERE status =2 AND clientSn=c.`sn` AND DATEDIFF(settlementDate,CURDATE())   <=7   \n\t\t\t\tAND DATEDIFF(settlementDate,CURDATE())   >=0   ) investBalance,\n\t\t\t    (SELECT IFNULL(SUM(capitalBalance), 0) + IFNULL(SUM(yieldBalance), 0)\n\t\t\t\tFROM view_client_invest_summary pr\n\t\t\t\tWHERE pr.clientSn = c.sn AND pr.status = 2 ) unclearedBalance,\n\t\t\t    (SELECT IFNULL(SUM(capitalBalance), 0) + cai.availableBalance + cai.frozenWithDraw +tra.availableBalance\n\t\t\t\tFROM view_client_invest_summary\n\t\t\t\tWHERE clientSn = c.sn AND status in(1,2)) totalBalance,\n\t\t\t    (cai.frozenWithDraw + cai.frozenPay) frozenBalance,(cai.availableBalance+tra.availableBalance) availableBalance\n\t\t    FROM\n\t\t        Client c \n\t\t        LEFT JOIN ClientExtraInfo cei on c.sn=cei.clientSn \n\t\t        LEFT JOIN Area area on cei.policyAreaSn=area.sn\n\t\t        LEFT JOIN AssignClientManager asm ON asm.clientSn=c.sn\n\t\t        LEFT JOIN ClientManager cm on cm.sn = asm.clientManagerSn\n\t\t        LEFT JOIN TransferClientAssetInfo tra on c.sn=tra.clientSn, \n\t\t        ClientPersonalInfo cp, ClientAssetInfo cai\n\t\t    WHERE\n\t\t        c.sn = cp.clientSn AND asm.status='1'\n\t\t            AND c.sn = cai.clientSn\n\t\t             \n\t\t       \t\t \n\t\t       \t\t\tAND exists (select * from ClientInvestOrder where clientSn = c.sn and status =3)\n\t\t       \t\t  \n\t\t       \t\t  \n\t\t            AND c.sn IN (SELECT \n\t\t                asm.clientSn\n\t\t            FROM\n\t\t                AssignClientManager asm\n\t\t            WHERE\n\t\t                asm.clientManagerSn IN \n\t\t                 (  \n                       \t\t 1600\n                \t\t ) \n                \t\t \n                \t\tAND asm.status='1')\t\t\n\t\t       ) t\n\t\t     \n\t\tORDER BY\n\t\t \n\t\tt.clientManagerSn desc,t.sn desc ) temp   limit 10,10;\n"
    ]
  ]
}

相关文章推荐

mysql logstash 配置

[elk@dr-mysql01 mysql]$ cat logstash_mysql.conf input { file { type => "zj_m...

Logstash实践之MySQL Slowlog解析

Logstash实践之MySQL Slowlog解析

用mysqldumpslow分析mysql的slow query log

mysql有一个功能就是可以log下来运行的比较慢的sql语句,默认是没有这个log的,为了开启这个功能,要修改my.cnf或者在mysql启动的时候加入一些参数。如果在my.cnf里面修改,需增加如...

mysql slow log分析工具的比较

mysql 中的 slow log 是用来记录执行时间较长(超过 long_query_time 秒)的 sql 的一种日志工具。       启用 slow log       在 my.c...

MySQL 日志之--慢查询日志(slow-query-log)

MySQL 日志之--慢查询日志(slow-query-log) 慢查询日志: MySQL慢查询日志记录下所有执行超过long_query_time时间的SQL语句,帮你找到执行慢的SQL,方便...
  • lqx0405
  • lqx0405
  • 2015年12月08日 15:51
  • 3642

MySQL开启慢查询日志log-slow-queries

一个普通WEB站点的页面常常需要查询N条SQL语句后才能得出页面结果,当网站访问速度慢而前端做了大量优化工作以后,数据库瓶颈的查找也是WEB优化的一个重要部分。 MySQL中提供了一个慢查询的日志记录...

MySQL开启慢查询日志slow_query_log

开启慢查询功能  slow_query_log_file 慢查询日志文件路径  slow_query_log 用于指定是否打开慢查询日志  long_query_time 超过多少秒的查询就写入日志...

五款常用mysql slow log分析工具的比较分析

mysql slow log 是用来记录执行时间较长(超过long_query_time秒)的sql的一种日志工具 启用 slow log 有两种启用方式: 1, 在my.cnf 里...

MySQL 之 slow log

慢查询有什么用?          它能记录下所有执行超过long_query_time时间的SQL语句,帮你找到执行慢的SQL,方便我们对这些SQL进行优化。    测试用 MySQL 版本...
  • jkh753
  • jkh753
  • 2013年09月12日 08:38
  • 4567

五款常用mysql slow log分析工具的比较

mysql slow log 是用来记录执行时间较长(超过long_query_time秒)的sql的一种日志工具. 启用 slow log 有两种启用方式: 1, 在my.cnf 里 ...
  • klarclm
  • klarclm
  • 2012年05月16日 13:51
  • 314
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:logstash 解析mysql slow log
举报原因:
原因补充:

(最多只允许输入30个字)