Email notification for different people?


(Feng Yu (Abcfy2)) #1

I want to email different people like this.

email {
    if [level] = "low" {
        to => "somepeole@domain"
    } else {
        to => "otherpeople@domain"
    }
    from => "foo"
    body => "%{message}"
 ...
}

But this config is error because of the syntax error. How to do this ?


(Simon Lundström) #2

On Fri, 2015-10-23 at 11:18:57 +0000, Feng Yu wrote:


(Magnus Bäck) #3
if [level] = "low" {

Change to:

if [level] == "low" {

(Feng Yu (Abcfy2)) #4

How about this ?

email {
    if "low level" in [message] {
        to => "somepeople@domain"
    } else {
        to => "otherpeople@domain"
    }
}

Error message:

Error: Expected one of #, => at line 45, column 16 (byte 951) after output {

        email {
            if

(Magnus Bäck) #5

No, you can't have conditionals inside input/output/filter declarations.


(Simon Lundström) #6

Since the forums email parsing is broken, here is my comment again:

Use the mutate filter[1] to add a field which contains the email address
then use that field in the to field in the email output (like you do
with message in the body field already).

1, https://www.elastic.co/guide/en/logstash/1.5/plugins-filters-mutate.html


(Feng Yu (Abcfy2)) #7

It's a good idea. But I faced an issue: https://github.com/logstash-plugins/logstash-output-email/issues/33

When used field as to, email plugin crashed.


(system) #8