• Mysql 利用multiline 实现多行匹配


    <pre name="code" class="html">input {
            file {
                    type => "zj_mysql"
                    path => ["/data01/applog_backup/zjzc_log/zj-mysql01-slowlog.*"]
            }
        
           file { 
                    type => "wj_mysql" 
                    path => ["/data01/applog_backup/winfae_log/wj-mysql01-slowlog.*"] 
            } 
    
    
        }
    
    
    filter {
    
    
       multiline {
                   pattern =>"^s+#s+Time:"
                   negate=>true
                   what=>"previous"
             }
     }
    
    
    output {
         if [type] == "zj_mysql" { 
            redis {
                    host => "192.168.32.67"
                    data_type => "list"
                    key => "zj_mysql:redis"
                    port=>"6379"
                    password => "1234567"
            }
    }
          else if [type] == "wj_mysql"{
           redis { 
                    host => "192.168.32.67" 
                    data_type => "list" 
                    key => "wj_mysql:redis" 
                    port=>"6379" 
                    password => "1234567" 
            } 
    }
    }
      
    multiline 多行匹配:
    
    这个插件很简单,就是把当前行的数据添加到前面一行后面,直到新进的当前行匹配^# Time:正则为止。
    
    看下slow log日志;
    
    LIMIT 0, 50;
     # Time: 160826 14:56:36
     # User@Host: zjzc_dba[zjzc_dba]
     # Query_time: 8.897828  Lock_time: 0.000263 Rows_sent: 1  Rows_examined: 25721574
     SET timestamp=1472194596;
     SELECT (SUM(repay.`yieldBalance`)-SUM(TRUNCATE(holding.`investBalance`*stock.productYield*pr.duration/pr.daysOfYear,pr.`precision`))) AS totalAddBenefit
     			FROM GambleStockIndex stock 
     			INNER JOIN `Product` po ON po.sn = stock.productSn
     			INNER JOIN ProductRepay pr on po.sn = pr.productSn
     			INNER JOIN `ClientInvestOrder` co ON co.`orderNo` = stock.`orderNo`
     			INNER JOIN `ClientProductHolding` holding ON holding.`investSn` = co.`sn`
     			INNER JOIN `ProductRepayment` repay ON repay.`holdingSn` = holding.`sn`
     		WHERE stock.`status`=2 and po.status =5
     LIMIT 0, 50;
     # Time: 160826 15:17:06
     # User@Host: zjzc_dba[zjzc_dba] @  [115.236.160.83]  Id: 5534343
     # Query_time: 8.842579  Lock_time: 0.000178 Rows_sent: 1  Rows_examined: 25721574
     SET timestamp=1472195826;
     SELECT (SUM(repay.`yieldBalance`)-SUM(TRUNCATE(holding.`investBalance`*stock.productYield*pr.duration/pr.daysOfYear,pr.`precision`))) AS totalAddBenefit
     			FROM GambleStockIndex stock 
     			INNER JOIN `Product` po ON po.sn = stock.productSn
     			INNER JOIN ProductRepay pr on po.sn = pr.productSn
     			INNER JOIN `ClientInvestOrder` co ON co.`orderNo` = stock.`orderNo`
     			INNER JOIN `ClientProductHolding` holding ON holding.`investSn` = co.`sn`
     			INNER JOIN `ProductRepayment` repay ON repay.`holdingSn` = holding.`sn`
     		WHERE stock.`status`=2 and po.status =5
     LIMIT 0, 50;
    


    
                                        
    
  • 相关阅读:
    ASP.NET 2.0 X64的奇怪问题
    【分享】从网上爬的WPF学习资料
    大家一起学习less 5:字符串插值
    大家一起学习less 3:命名空间
    我的模块加载系统 v18
    大家一起学习less 2:自带函数
    “计算机之子”的MVVM框架源码学习笔记
    我的MVVM框架 v0.1发布
    大家一起学习less 6:一些有用的混合函数
    less源码学习
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350348.html
Copyright © 2020-2023  润新知