Logstash电子邮件警报

时间:2014-08-14 19:19:50

标签: email message logstash alerts

我将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}"
        }
    }
}

2 个答案:

答案 0 :(得分:3)

在这种情况下,字段名称为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}"

答案 1 :(得分:0)

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

相关问题