logstash.conf 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. input {
  2. syslog {
  3. type => syslog
  4. port => 5544
  5. }
  6. file {
  7. type => "syslog"
  8. path => "/var/log/messages"
  9. start_position => "beginning"
  10. }
  11. # lumberjack {
  12. # # The port to listen on
  13. # port => 12345
  14. #
  15. # # The paths to your ssl cert and key
  16. # ssl_certificate => "/etc/logstash/logstash-forwarder.crt"
  17. # ssl_key => "/etc/logstash/logstash-forwarder.key"
  18. #
  19. # # Set this to whatever you want.
  20. # type => "logs"
  21. # }
  22. }
  23. filter {
  24. if [type] == "syslog" {
  25. grok {
  26. match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} (%{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}|%{GREEDYDATA:syslog_message})" }
  27. add_field => [ "received_at", "%{@timestamp}" ]
  28. add_field => [ "received_from", "%{@source_host}" ]
  29. }
  30. if !("_grokparsefailure" in [tags]) {
  31. mutate {
  32. replace => [ "@source_host", "%{syslog_hostname}" ]
  33. replace => [ "@message", "%{syslog_message}" ]
  34. }
  35. }
  36. mutate {
  37. remove_field => [ "syslog_hostname", "syslog_message" ]
  38. }
  39. date {
  40. match => [ "syslog_timestamp","MMM d HH:mm:ss", "MMM dd HH:mm:ss", "ISO8601" ]
  41. }
  42. syslog_pri { }
  43. }
  44. }
  45. output {
  46. elasticsearch {
  47. hosts => ["localhost"]
  48. }
  49. }