ELK—filebeat收集单个类型日志写入redis

Filebeat 支持将数据直接写入到 redis 服务器,本步骤为写入到 redis ,另外 filebeat 还支持写入到 elasticsearch、logstash 等服务器。

grep -v "#" /etc/filebeat/filebeat.yml | grep -v "^$"
filebeat.prospectors:
- input_type: log
  paths:
    - /var/log/messages
    - /var/log/*.log
  exclude_lines: ["^DBG","^$"]
  document_type: system-log-1512

output.redis:
  hosts: ["192.168.15.12:6379"]
  key: "system-log-1512" #为了后期日志处理,建议自定义 key 名称
  db: 1 #使用第几个库
  timeout: 5 #超时时间
  password: 123456 #redis 密码

配置 logstash 从 redis 读取上面的日志

cat /etc/logstash/conf.d/redis-systemlog-es.conf
input {
  redis {
    host => "192.168.15.12"
    port => "6379"
    db => "1"
    key => "system-log-1512"
    data_type => "list"
  }
}

output {
  if [type] == "system-log-1512" {
    elasticsearch {
      hosts => ["192.168.15.11:9200"]
      index => "system-log-1512"
    }
  }
}

 

posted @ 2022-05-16 11:29  不会跳舞的胖子  阅读(208)  评论(0)    收藏  举报