如何将redis配置为在elk中充当消息队列,并在消息消耗时清除磁盘空间

时间:2016-06-16 14:34:55

标签: elasticsearch redis logstash kibana filebeat

我的ELK设置如下 Kibana< - ElasticSearch< - Logstash< - FileBeat(从不同日志源获取日志)
当消息流入更多时,此设置会中断。正如我在互联网上阅读的那样,人们建议在此设置中使用redis为ES消耗信息腾出空间。所以我现在希望设置这样的东西 Kibana< - ElasticSearch< - Logstash< - REDIS< - FileBeat(从不同日志源获取日志)
我希望Redis充当中间人来保存消息,以便消费者端不会出现瓶颈。但是这里的redis dump.rdb一直在增长,一旦logstash消息消息,它就不会收缩(不会释放空间)。 下面是我的redis.conf

a <- sapply(1:length(x),  function(i) {
res <- c(i, paste(ex_dollar(x[i])), unlist(stringr::str_extract_all(text[i], paste(toMatch, collapse = "|"))))
if (length(res) > 1 ) {res
  } else NULL
})

编辑:FileBeat config:

bind host
port port
tcp-backlog 511
timeout 0
tcp-keepalive 0
daemonize no
supervised no
pidfile /var/run/redis.pid
loglevel notice
logfile "/tmp/redis.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ./
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

Logstash配置:

filebeat:
  prospectors:
    -
      paths:
        - logPath
      input_type: log
      tail_files: true
output:
   redis:
     host: "host"
     port: port
     save_topology: true
     index: "filebeat"
     db: 0
     db_topology: 1
     timeout: 5
     reconnect_interval: 1
shipper:
logging:
  to_files: true
  files:
    path: /tmp
    name: mybeat.log
    rotateeverybytes: 10485760
  level: warning

如果需要更多信息,请与我们联系。 TIA !!!

1 个答案:

答案 0 :(得分:0)

我认为您的问题可能与消息从Redis存储和检索的方式有关。

理想情况下,您应该使用Redis的List数据结构,使用LPUSHLPOP分别插入和检索邮件。