@PhaedrusTheGreek thanks for the guidance on this. I didn't realize (I should have) that nagioscheckbeat outputs both metrics and status in different types. This is great!
I've set up a test where one server is running nagioscheckbeat and outputting that data to my logstash server. I've configured a new pipeline to accept the "nagiosmetric" data and that is working well
I'm having a problem getting nagios_nsca to function. I keep getting
error=>#<TypeError: no implicit conversion of Integer into String
Here is my config:
input {
beats {
port => 5074
type => "nagioscheckbeats"
ssl => true
ssl_certificate_authorities => ["/etc/logstash/certs/cacert.pem"]
ssl_certificate => "/etc/logstash/certs/{{ inventory_hostname }}.crt"
ssl_key => "/etc/logstash/certs/{{ inventory_hostname }}-logstash.pem"
ssl_verify_mode => "force_peer"
}
}
filter {
if [type] =~ "nagiosmetric" {
mutate {
convert => { "name" => "string" }
convert => { "status_code" => "string" }
convert => { "message" => "string" }
}
}
}
output {
if [type] == "nagiosmetric" {
elasticsearch {
hosts => [{{ logstash_elasticsearch_hosts }}]
user => {{ xpack_management_elasticsearch_username }}
password => {{ xpack_management_elasticsearch_password }}
cacert => "{{ logstash_ssl_dir }}/{{ logstash_ssl_certificate_file }}"
ssl_certificate_verification => false
index => "nagioscheckbeat-%{+YYYY.MM.dd}"
}
} else {
nagios_nsca {
host => "{{nagios_server}}"
port => 5667
nagios_service => "%{name}"
nagios_status => "%{[status_code]}"
nagios_host => "%{[beat][hostname]}"
message_format => "%{name}: %{message}"
}
# used for debugging
#file {
# path => "/tmp/logstash-output.txt"
# codec => line { format => "custom format: %{message}"}
#}
}
}
The debug output is:
[2019-08-31T02:12:26,725][DEBUG][logstash.outputs.nagiosnsca] Running send_nsca command {:nagios_nsca_command=>"/usr/sbin/send_nsca -H xxxx.xxxx.com -p 5667 -d :", :message=>"xxxx.xxxx.com:heartbeat:0:heartbeat: OK: Hello<br/>"}
[2019-08-31T02:12:26,727][WARN ][logstash.outputs.nagiosnsca] Skipping nagios_nsca output; error calling send_nsca {:error=>#<TypeError: no implicit conversion of Integer into String>, :nagio
s_nsca_command=>"/usr/sbin/send_nsca -H xxxx.xxxx.com -p 5667 -d :", :message=>"xxxx.xxxx.com:heartbeat:0:heartbeat: OK: Hello<br/>", :missed_event=>#<LogStash::Event:0x669acbab>}
[2019-08-31T02:12:26,727][DEBUG][logstash.outputs.nagiosnsca] Backtrace {:backtrace=>["org/jruby/RubyProcess.java:1567:in `spawn'", "org/jruby/RubyKernel.java:1646:in `spawn'", "uri:classload
er:/META-INF/jruby.home/lib/ruby/stdlib/open3.rb:202:in `popen_run'", "uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/open3.rb:98:in `popen3'", "/usr/share/logstash/vendor/bundle/jruby/
2.5.0/gems/logstash-output-nagios_nsca-3.0.6/lib/logstash/outputs/nagios_nsca.rb:135:in `send_to_nagios'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-output-nagios_nsca-3.0.
6/lib/logstash/outputs/nagios_nsca.rb:110:in `receive'", "/usr/share/logstash/logstash-core/lib/logstash/outputs/base.rb:89:in `block in multi_receive'", "org/jruby/RubyArray.java:1792:in `ea
ch'", "/usr/share/logstash/logstash-core/lib/logstash/outputs/base.rb:89:in `multi_receive'", "org/logstash/config/ir/compiler/OutputStrategyExt.java:118:in `multi_receive'", "org/logstash/co
nfig/ir/compiler/AbstractOutputDelegatorExt.java:101:in `multi_receive'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:235:in `block in start_workers'"]}
which seems to indicate that the error is on line 135 of the nagios_nsca.rb file. I'm not very familiar with Ruby, so this is my best attempt to track down the root of the error, but I accept that it's likely that I'm wrong.
line 104 of nagios_nsca.rb says:
message = "#{nagios_host}:#{nagios_service}:#{status}:#{msg}"
So, I can see how it's combining multiple variables into one - which might be where the integer is getting pulled in. But, I don't see any integer. I've even tried to use mutate to convert fields to strings, but that didn't seem to affect anything.
Line 135 of nagios_nsca.cfg says:
i.puts(message)
Where is the integer? How do I remove this error? Any help would be greatly appreciated.