0

I have a code in Ruby (as a Logstash plugin) in which I connect to Redis and get information like what is suggested in (How to use redis inside logstash filter?) as below:

require "redis"
$redis = Redis.new(host: "REDIS_HOST", port: REDIS_PORT, db: REDIS_DB)

@my_data = $redis.hget("DATA_KEY", "HASH_FIELD").to_i

Everything works OK generally; however, I want to know:

1- Which possible errors might be faced by the code while connecting to Redis or getting data (e.g. Redis is unreachable or DATA_KEY or HASH_FIELD does not exist)

2- How should we handle such errors?

0 Answers0