【问题标题】:Logstash email alertsLogstash 电子邮件警报
【发布时间】:2014-08-14 19:19:49
【问题描述】:

我将 logstash 配置为发送电子邮件警报,以防日志消息中出现某些单词组合。我收到警报,但没有收到警报中的消息字段值,而是收到“@message”一词。 我该如何解决这个问题?

这是我的 logstash 配置文件:

root@srv-syslog:~# cat /etc/logstash/conf.d/central.conf
input {
    syslog {
        type => "syslog"
        port => 5144
    }
    tcp {
        type => "cisco_asa"
        port => 5145
    }
    tcp {
        type => "cisco_ios"
        port => 5146
    }
}
output {
    elasticsearch {
        bind_host => "127.0.0.1"
        port => "9200"
        protocol => http
    }
    if "executed the" in [message]  {
        email {
            from => "logstash_alert@company.local"
            subject => "logstash alert"
            to => "myemail@company.local"
            via => "smtp"
            body => "Here is the event line that occured: %{@message}"
        }
    }
}

【问题讨论】:

    标签: email message logstash alerts


    【解决方案1】:

    本例中的字段名称是message,而不是@message

    查看演示:

    input {
        generator {
            count => 1
            lines => ["Example line."]
        }
    }
    
    filter {
        mutate {
            add_field => {
                "m1" => "%{message}"
                "m2" => "%{@message}"
            }
        }
    }
    
    output {
        stdout {
            codec => rubydebug{}
        }
    }
    

    在你的情况下,你应该只需要修复一行:

    body => "Here is the event line that occured: %{message}"
    

    【讨论】:

      【解决方案2】:

      删除@符号。该字段是消息,而不是@message。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-03-21
        • 1970-01-01
        • 1970-01-01
        • 2017-05-05
        相关资源
        最近更新 更多