Guest User

Untitled

a guest
Oct 27th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. ######### application.properties
  2. # trace and span taken from MDC context. Hostname could be redundant is using FileBeat on same host,
  3. # but maybe you are feeding logs to ES in another way. Including it in the log covers this possibility
  4.  
  5. logging.pattern.file=%d{ABSOLUTE} [%X{traceId}-%X{spanId}] %-5p ${HOSTNAME} ${PID} [%t] [%C{2}] [%F:%L] - %m%n
  6.  
  7.  
  8.  
  9. ######### pipeline/logstash.conf
  10. # There is an old saying. You had a problem. You solved it with regex. Now you have 2 problems.
  11. # Really, you can address this is a simpler way by using || or [] separators between each field,
  12. # but anyhow, where's the fun in that.
  13. # Note that if you do not add the date mutation, the timestamp in ES will be the time it was received from the FileBeat
  14. # as opposed to the timestamp of the log message. And that is bad.
  15. input {
  16. beats {
  17. port => 5044
  18. }
  19. }
  20. filter {
  21. grok {
  22. match => [ "message",
  23. "(?<timestamp>%{YEAR}-%{MONTHNUM}-%{MONTHDAY} %{TIME}) \[(?<traceid>[a-f0-9]*)-(?<spanid>[a-f0-9]*)\] %{LOGLEVEL:level}\s+(?<hostname>[a-zA-Z0-9.-]*)\s+%{NUMBER:pid}\s*\[(?<thread>[A-Za-z0-9-]+)\]\s*\[[A-Za-z0-9.]*\.(?<class>[A-Za-z0-9#_]+)\] \[(?<file>[A-Za-z0-9.]+)\:(?<line>[0-9]+)\]\s*\-\s*(?<logmessage>.*)" ]
  24. }
  25. date {
  26. locale => "en"
  27. timezone => "UTC"
  28. match => ["timestamp", "yyyy-MM-dd HH:mm:ss,SSS"]
  29. target => "@timestamp"
  30. remove_field => ["timestamp", "monthday", "year", "month", "day", "time"]
  31. }
  32. }
  33. output {
  34.  
  35. elasticsearch {
  36. hosts => ["elasticsearch:9200"]
  37. user => elastic
  38. password => changeme
  39. index => "logstash-%{+YYYY.MM.dd}"
  40. }
  41. stdout {
  42. codec => rubydebug
  43. }
  44. }
Add Comment
Please, Sign In to add comment