Class: LogStash::Outputs::Syslog
- Defined in:
- lib/logstash/outputs/syslog.rb
Overview
Send events to a syslog server.
You can send messages compliant with RFC3164 or RFC5424 UDP or TCP syslog transport is supported
Constant Summary collapse
- FACILITY_LABELS =
[ "kernel", "user-level", "mail", "daemon", "security/authorization", "syslogd", "line printer", "network news", "uucp", "clock", "security/authorization", "ftp", "ntp", "log audit", "log alert", "clock", "local0", "local1", "local2", "local3", "local4", "local5", "local6", "local7", ]
- SEVERITY_LABELS =
[ "emergency", "alert", "critical", "error", "warning", "notice", "informational", "debug", ]
Constants included from Config::Mixin
Instance Attribute Summary
Attributes included from Config::Mixin
Attributes inherited from Plugin
Instance Method Summary collapse
Methods inherited from Base
#handle, #handle_worker, #initialize, #worker_setup, #workers_not_supported
Methods included from Config::Mixin
Methods inherited from Plugin
#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s
Constructor Details
This class inherits a constructor from LogStash::Outputs::Base
Instance Method Details
#receive(event) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/logstash/outputs/syslog.rb', line 112 def receive(event) return unless output?(event) appname = event.sprintf(@appname) procid = event.sprintf(@procid) sourcehost = event.sprintf(@sourcehost) facility_code = FACILITY_LABELS.index(@facility) severity_code = SEVERITY_LABELS.index(@severity) priority = (facility_code * 8) + severity_code if rfc3164? = event.sprintf("%{+MMM dd HH:mm:ss}") syslog_msg = "<"+priority.to_s()+">"++" "+sourcehost+" "+appname+"["+procid+"]: "+event["message"] else msgid = event.sprintf(@msgid) = event.sprintf("%{+YYYY-MM-dd'T'HH:mm:ss.SSSZ}") syslog_msg = "<"+priority.to_s()+">1 "++" "+sourcehost+" "+appname+" "+procid+" "+msgid+" - "+event["message"] end begin connect unless @client_socket @client_socket.write(syslog_msg + "\n") rescue => e @logger.warn(@protocol+" output exception", :host => @host, :port => @port, :exception => e, :backtrace => e.backtrace) @client_socket.close rescue nil @client_socket = nil end end |
#register ⇒ Object
87 88 89 |
# File 'lib/logstash/outputs/syslog.rb', line 87 def register @client_socket = nil end |