How to send email

I used logstash 2.2 version,Use the following configuration

output {

if [beat_ip] != "%{tags[1]}" {
elasticsearch {
hosts => ["localhost:9200"]
index => "logstash-%{type}-%{+YYYY.MM.dd}"
document_type => "%{type}"
}

  if [type] == "system" {
if ([mem.used_p] >= 0.8) {
  email {
    to => "abc@abc.com"
    from => "xyz@xyz.com"
    address => "192.168.10.236"
    port => 25
    via => "smtp"      
    subject => "Warning:  %{mem.used_p}"
    htmlbody => "<h1>total:%{mem.total}</h1><h2>used:%{mem.used}</h2><h3>free:%{mem.free}</h3>"
    password => "123344455"
    username => "abc@aa.com"      
  }    
}

}
}

But console raise error:

C:\Program Files\logstash>bin\logstash -f beats.conf
io/console not supported; tty will not be manipulated
Settings: Default pipeline workers: 4
Logstash startup completed
NoMethodError: undefined method `>=' for nil:NilClass
output_func at (eval):58
output_batch at C:/Program Files/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.2.2-java/lib/logstash/pipeline.rb:282
each at org/jruby/RubyArray.java:1613
inject at org/jruby/RubyEnumerable.java:852
output_batch at C:/Program Files/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.2.2-java/lib/logstash/pipeline.rb:276
worker_loop at C:/Program Files/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.2.2-java/lib/logstash/pipeline.rb:221
start_workers at C:/Program Files/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-2.2.2-java/lib/logstash/pipeline.rb:190

C:\Program Files\logstash>

Thanks

if ([mem.used_p] >= 0.8) {

That's the wrong syntax for nested fields. See Accessing event data and fields | Logstash Reference [8.11] | Elastic.

1 Like

Use the following method to resolve

single field ===> [type]
not single field ===> [mem][used]

Thanks very much.