Email notification for different people?

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 ?

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

if [level] = "low" {

Change to:

if [level] == "low" {

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

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

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

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.