cgswong

logstash-test.conf

Jun 29th, 2015
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. # Where to get input
  2. input {
  3. # syslog inputs
  4. tcp {
  5. port => 5000
  6. type => "syslog"
  7. }
  8. udp {
  9. port => 5000
  10. type => "syslog"
  11. }
  12.  
  13. # CoreOS journal input
  14. tcp {
  15. codec => "line"
  16. port => 5004
  17. tags => ["coreos","docker"]
  18. type => "systemd"
  19. }
  20.  
  21. # Logspout input
  22. udp {
  23. codec => "plain"
  24. port => 5006
  25. tags => ["docker"]
  26. type => "logspout"
  27. }
  28.  
  29. # Log4j application input
  30. log4j {
  31. codec => "json_lines"
  32. port => 5200
  33. tags => ["applogs","service"]
  34. type => "log4j"
  35. }
  36. }
  37.  
  38. # Some Filtering
  39. filter {
  40. # syslog/systemd filter
  41. if [type] == "syslog" or [type] == "systemd" {
  42. grok {
  43. match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{SYSLOGPROG}: %{GREEDYDATA:syslog_message}" }
  44. add_field => [ "received_at", "%{@timestamp}" ]
  45. }
  46. syslog_pri { }
  47. date { match => [ "syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ] }
  48.  
  49. if !("_grokparsefailure" in [tags]) {
  50. mutate {
  51. replace => { "message" => "%{syslog_message}" }
  52. remove_field => [ "syslog_message", "syslog_program" ]
  53. }
  54. }
  55.  
  56. # Remove spurious fields that have names changed or been aggregated
  57. mutate { remove_field => [ "syslog_hostname", "syslog_timestamp" ] }
  58. }
  59.  
  60. # Docker filter
  61. if [program] == "dockerd" {
  62. kv {
  63. source => "message"
  64. remove_field => [ "time" ]
  65. prefix => "docker_"
  66. }
  67. mutate { rename => { "docker_level" => "docker_loglevel" } }
  68. # mutate {
  69. # replace => { "message" => "time=\"%{TIMESTAMP_ISO8601:docker_ts}\" level=%{LOGLEVEL:docker_loglevel} msg=\"%{GREEDYDATA:docker_msg}\"" }
  70. # }
  71. if !("_grokparsefailure" in [tags]) {
  72. mutate {
  73. replace => { "message" => "%{docker_msg}" }
  74. remove_field => [ "%{docker_msg}" ]
  75. }
  76. }
  77. }
  78.  
  79. # Logspout filter
  80. if [type] == "logspout" {
  81. grok {
  82. match => { "message" => "%{SYSLOG5424PRI}%{NONNEGINT:ver} +(?:%{TIMESTAMP_ISO8601:ts}|-) +(?:%{HOSTNAME:containerid}|-) +(?:%{NOTSPACE:containername}|-) +(?:%{NOTSPACE:proc}|-) +(?:%{WORD:msgid}|-) +(?:%{SYSLOG5424SD:sd}|-|) +%{GREEDYDATA:msg}" }
  83. }
  84. syslog_pri { }
  85. date { match => [ "syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ] }
  86. if !("_grokparsefailure" in [tags]) {
  87. mutate {
  88. replace => { "@source_host" => "%{syslog_hostname}" }
  89. replace => { "message" => "%{syslog_message}" }
  90. }
  91. }
  92.  
  93. # Remove spurious fields that have names changed or been aggregated
  94. mutate { remove_field => [ "syslog_hostname", "syslog_message", "syslog_timestamp" ] }
  95. }
  96.  
  97. # Add GeoIP
  98. geoip { source => "%{IPORHOST}" }
  99. }
  100.  
  101. # Where to send output
  102. output {
  103. # Send output to standard output device/interface
  104. stdout {
  105. codec => rubydebug
  106. }
  107.  
  108. # Parse failed messages to separate index
  109. if "_grokparsefailure" in [tags] or "_jsonparsefailure" in [tags] {
  110. elasticsearch {
  111. # host => ["localhost:9200"]
  112. host => ["ES_CONN_STR"]
  113. index => "parse-err-%{+YYYY.MM.dd}"
  114. protocol => "http"
  115. }
  116. }
  117.  
  118. # Elasticsearch output
  119. elasticsearch {
  120. # host => ["localhost:9200"]
  121. host => ["ES_CONN_STR"]
  122. index => "logstash-%{+YYYY.MM.dd}"
  123. protocol => "http"
  124. }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment