传统运维 - ilogtail解析自建Mysql slow sql

2021-11-12

日志样例

# Time: 210916 14:16:11
# User@Host: root[root] @  [10.244.9.91]  Id: 10248
# Query_time: 11.144143  Lock_time: 0.000253 Rows_sent: 1  Rows_examined: 684456
use activiti;
SET timestamp=1631772971;
select

    id, exchange, routing_key, msg, send_result, event_type, execution_id, process_instance_id, process_definition_id,
    task_id, entity_class, update_status, send_msg, data_sync,
    created_date,updated_date,is_active

    from yqn_act_event_record
    where (send_result = 0 or update_status = 0 or send_msg = 0 or data_sync = 0)
    and   left(process_definition_id, 4) <> 'seo_'
    and   (unix_timestamp( now() ) -unix_timestamp(updated_date)  > 120)   limit 20;

行首正则表达式

#\sTime:\s(\d+)\s([\d\:]+)

正则

#\sTime:\s([\s\d\:]+)#\sUser@Host:\s([\[\S\]@\.\s]*?)Id:\s+(\d+)\s#\sQuery_time:\s([\d\.]+)\s+Lock_time:\s([\d\.]+)\sRows_sent:\s(\d+)\s\sRows_examined:\s(\d+)(\suse\s(\S+);)?\sSET\stimestamp=(\d+);\s([\s\S]*)

日志提取

image.png

java stdout

([\s\d\-]+\s[\s\d\:]+)\|([0-9.]+)\|([a-z-_]+)\|([a-z,-]+)\s?([a-zA-Z\s]+)\|([A-Z]+)\s\|([\s\S]*)
2021-11-10 18:51:06|192.168.160.58|supplier-service|xxl-job, executor ExecutorRegistryThread|INFO |c.x.r.r.invoker.reference.XxlRpcReferenceBean|>>>>>>>>>>> xxl-rpc, invoke error, address:http://42003.pr.yqn.corp:42003/api, XxlRpcRequestXxlRpcRequest{requestId='0d70a22c-5ab3-4de0-985f-410517a47035', createMillisTime=1636541465374, accessToken='', className='com.xxl.job.core.biz.AdminBiz', methodName='registry', parameterTypes=[class com.xxl.job.core.biz.model.RegistryParam], 

参考文档

https://help.aliyun.com/document_detail/38896.html
https://help.aliyun.com/document_detail/137902.htm
https://regex101.com/?spm=a2c4g.11186623.0.0.301d4e95NPrVE9


标题:传统运维 - ilogtail解析自建Mysql slow sql
地址:https://blog.njqhome.com:8443/articles/2021/09/22/1632280196557.html