zoukankan      html  css  js  c++  java
  • logstash 发送zabbix告警

    <pre name="code" class="html">[elk@dr-mysql01 test]$ cat t1.conf 
    input {
        stdin {
        }
    }
    
    filter {
        grok {
            match => [
                 "message" , "s*%{IPORHOST:clientip}s+-s+-s+[%{HTTPDATE:time}]s+"%{WORD:verb}s+(?<api>(S+))?.*s+HTTP/%{NUMBER:httpversion}"s+%{NUMBER:http_status_code}s+%{NUMBER:bytes}s+(%{BASE16FLOAT:request_time})s+%{IPORHOST:remoteip}",
                  "message" ,"s*%{IPORHOST:clientip}s+-s+-s+[%{HTTPDATE:time}]s+"%{WORD:verb}s+(?<api>(S+))s+HTTP/%{NUMBER:httpversion}"s+%{NUMBER:http_status_code}s+%{NUMBER:bytes}s+(%{BASE16FLOAT:request_time})s+%{IPORHOST:remoteip}",
                 "message" ,"s*%{IPORHOST:clientip}s+-s+-s+[%{HTTPDATE:time}]s+"%{WORD:verb}s+(?<api>(S+))s+HTTP/%{NUMBER:httpversion}"s+%{NUMBER:http_status_code}s+-s+(%{BASE16FLOAT:request_time})s+%{IPORHOST:remoteip}"
            ]
        }   
            mutate {
                            convert => [ "request_time", "float"]
                           add_field =>["response_time","%{request_time}"]
                            remove_field =>["request_time"]
                           add_field => [ "[@metadata][zabbix_key]" , "logstash-api-access" ]
                           add_field => [ "[@metadata][zabbix_host]" , "dr-mysql01" ]
                            
                    }
       date {
            match => ["time", "dd/MMM/yyyy:HH:mm:ss Z"]
        }
         
    }
    
    output {
    if [response_time] >= 5  {
    zabbix {
    		zabbix_host => "[@metadata][zabbix_host]"
    		zabbix_key => "[@metadata][zabbix_key]"
            zabbix_server_host => "192.168.32.55"
            zabbix_server_port => "10051"
    		zabbix_value => "message"
            }
    }
     stdout {
                            codec => rubydebug
                    } 
      
    }
    
    
    这里的 [ "[@metadata][zabbix_host]" , "dr-mysql01" ] host是指zabbix里配置的主机名
    
    [ "[@metadata][zabbix_key]" , "logstash-api-access" ] zabbix 配置的key


    
                                        
    
  • 相关阅读:
    java.lang.ClassNotFoundException: com.sun.tools.javac.Main (Liferay运行ant build.xml执行错误)
    JS正则验证手机号码或者电话号码(转)
    ResultSet用法
    IntelliJ IDEA 快捷键和设置
    Ext.MessageBox消息框
    vim + cscope + ctags + taglist配置
    ExtJs 确认密码验证的实现
    一道关于排列组合的算法题
    把Boost更新到了1.35
    发布Flv合并器的.net版
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350249.html
Copyright © 2011-2022 走看看