'Scan keys on Redis using Ruby code in Logstasg
I use a pipeline in Logstash that have a config file of Ruby codes.
In this file, I scan all logs in that pipeline with word table.
I follow this structure as below:
def filter(event)
red = Redis.new(host: "127.0.0.1", port: 6379, db: 7)
start = 0
key_collection = []
index, keys = red.scan(start)
while index != "0"
start = index
keys.each do |key|
key_collection << key if key.include?('table')
end
index, keys = red.scan(start)
end
event.set(@is_valid, key_collection)
return [event]
end
Is this way correct?
The key_collection << key if key.include?('table') does not work. How can I add all keys that include 'table*' in an array?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
