使用filebeat接收json日志文件

jobtbby3  于 2021-06-15  发布在  ElasticSearch
关注(0)|答案(1)|浏览(495)

所以我有一个日志文件,它的每一行都是一个json对象。我希望能够将此日志文件直接发送到elasticsearch,然后希望elastic能够接收数据。
我很确定我需要为此声明一个特定的模板。然而,我不知道如何,并将很高兴有一些指导如何做的权利。

nhaq1z21

nhaq1z211#

  1. # Filebeat Configuration
  2. filebeat:
  3. # List of prospectors to fetch data.
  4. prospectors:
  5. # Each - is a prospector. Below are the prospector specific configurations
  6. -
  7. paths:
  8. #- /var/log/*.log
  9. - ${applicationLogsPath}
  10. document_type: application_logs
  11. # Mutiline can be used for log messages spanning multiple lines.
  12. multiline:
  13. # The regexp Pattern that has to be matched. The example pattern matches all lines starting with [
  14. pattern: ^%{TIMESTAMP_ISO8601}
  15. # Defines if the pattern set under pattern should be negated or not. Default is false.
  16. negate: true
  17. # Match can be set to "after" or "before". It is used to define if lines should be append to a pattern
  18. # that was (not) matched before or after or as long as a pattern is not matched based on negate.
  19. # Note: After is the equivalent to previous and before is the equivalent to to next in Logstash
  20. match: after
  21. # Additional prospector
  22. -
  23. paths:
  24. - ${iisLogsPath}
  25. document_type: iis_logs
  26. # Configure what outputs to use when sending the data collected by the beat.
  27. # Multiple outputs may be used.
  28. output:
  29. ### Logstash as output
  30. elasticsearch:
  31. # The elasticsearch hosts
  32. hosts: ["${elasticsearchHost}:9200"]
  33. # Number of workers per Logstash host.
  34. #worker: 1
  35. # The maximum number of events to bulk into a single batch window. The
  36. # default is 2048.
  37. #bulk_max_size: 2048

这是一个默认模板,我使用它通过filebeat将日志接收到elasticsearch中。。您还可以将日志发送到logstash并过滤日志以捕获必要的信息,然后让logstash将日志转发到elasticsearch。。
如果你还需要什么,请告诉我。。
谢谢,

展开查看全部

相关问题