date: 2021-02-01title: logstash线上配置文件 #标题
tags: logstash #标签
categories: elastic stack # 分类

线上logstash配置文件,特此记录。

pipelines.yml 文件

  1. $ egrep -v '^$|^#' pipelines.yml
  2. - pipeline.id: feature
  3. path.config: "/data/elk/logstash-7.5.0/conf.d/kafka-feature.conf"
  4. - pipeline.id: feature-log
  5. path.config: "/data/elk/logstash-7.5.0/conf.d/kafka-feature-log.conf"
  6. - pipeline.id: report
  7. path.config: "/data/elk/logstash-7.5.0/conf.d/kafka-report.conf"
  8. - pipeline.id: device
  9. path.config: "/data/elk/logstash-7.5.0/conf.d/kafka-devicelog.conf"
  10. - pipeline.id: main
  11. path.config: "/data/elk/logstash-7.5.0/conf.d/kafka-reqlog.conf"

logstash 配置文件

  1. $ egrep -v '^$|^#' logstash.yml
  2. pipeline.workers: 32
  3. pipeline.batch.size: 1000
  4. pipeline.batch.delay: 50

任意一个.conf 文件

  1. cat kafka-devicelog.conf
  2. input{
  3. kafka {
  4. bootstrap_servers => "kafka01:9092,kafka02:9092,kafka03:9092"
  5. auto_offset_reset => "latest"
  6. topics => ["deviceRequestLog"]
  7. client_id => "dev-no01"
  8. group_id => "logstash-devlog"
  9. decorate_events => true
  10. }
  11. }
  12. filter{
  13. json {
  14. source => "message"
  15. }
  16. mutate {
  17. remove_field => ["message"]
  18. add_field => { "@kafka_timestamp" => "" }
  19. }
  20. date {
  21. match => ["[@metadata][kafka][timestamp]","UNIX_MS"]
  22. target => "@kafka_timestamp"
  23. }
  24. # 解决8小时时差问题
  25. ruby {
  26. code => "event.set('timestamp', event.get('req_time') + 8*60*60*1000)"
  27. }
  28. date {
  29. match => ["timestamp", "UNIX_MS"]
  30. target => "@timestamp"
  31. }
  32. mutate {
  33. remove_field => ["timestamp"]
  34. }
  35. }
  36. output {
  37. elasticsearch {
  38. hosts => ["es01:9200","es02:9200","es03:9200"]
  39. index => "device-log-%{+YYYY-MM-dd}"
  40. user => "elastic"
  41. password => "ppasswd"
  42. }
  43. }