# Trying to understand how Logstash Redis input plugin works

**URL:** <https://discuss.elastic.co/t/trying-to-understand-how-logstash-redis-input-plugin-works/313042>\
**Category:** Logstash\
**Created:** [August 26, 2022, 6:14pm UTC](https://discuss.elastic.co/t/trying-to-understand-how-logstash-redis-input-plugin-works/313042 "2022-08-26T18:14:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ImranArif](https://avatars.discourse-cdn.com/v4/letter/i/a5b964/32.png) [@ImranArif](https://discuss.elastic.co/u/ImranArif)\
**Post date:** [August 26, 2022, 6:14pm UTC](https://discuss.elastic.co/t/trying-to-understand-how-logstash-redis-input-plugin-works/313042/1 "2022-08-26T18:14:12Z")

</div>

Hi,  
Please consider the following input plugin configuration of Logstash:

```auto
input {
  redis {
    host => "es1"
    port => 6380
    batch_count => 2000
    data_type => "list"
    key => "log_list"
    codec => plain
  }
}

```

I am trying to understand how does a redis input plugin of Logstash reads log files from Redis. I specifically want to know how does Logstash gets notified when a new log is available to be read or does it run a cron job to read log files from Redis server? Also, what does "list" data type and batch\_count signifies as to how the data is read?

I have these confusions, and would be grateful if someone can provide some clarification please.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [August 26, 2022, 8:10pm UTC](https://discuss.elastic.co/t/trying-to-understand-how-logstash-redis-input-plugin-works/313042/2 "2022-08-26T20:10:01Z")

</div>

For a list, if batch\_count is greater than one then the code sits in [a loop](https://github.com/logstash-plugins/logstash-input-redis/blob/71d3ee5d75bd42458685e0ffd0520727d9ccaa21/lib/logstash/inputs/redis.rb#L184) making [EVALSHA calls](https://github.com/logstash-plugins/logstash-input-redis/blob/71d3ee5d75bd42458685e0ffd0520727d9ccaa21/lib/logstash/inputs/redis.rb#L195) to a server side script. If the result set is empty then it does 'sleep 0.25'.

If batch\_count is 1 then the code sits in a loop making [BLPOP calls](https://github.com/logstash-plugins/logstash-input-redis/blob/71d3ee5d75bd42458685e0ffd0520727d9ccaa21/lib/logstash/inputs/redis.rb#L233) (which block until data is available or a timeout occurs).

If you use channel rather than list then code will [subscribe](https://github.com/logstash-plugins/logstash-input-redis/blob/71d3ee5d75bd42458685e0ffd0520727d9ccaa21/lib/logstash/inputs/redis.rb#L310) to the channel. The subscribe call blocks and invokes the code block it is given each time a message arrives. The internals of how that works (polling, blocking etc. are a redis client question, not a logstash question).

---

<div class="post-metadata">

**Author:** ![ImranArif](https://avatars.discourse-cdn.com/v4/letter/i/a5b964/32.png) [@ImranArif](https://discuss.elastic.co/u/ImranArif)\
**Post date:** [August 26, 2022, 8:38pm UTC](https://discuss.elastic.co/t/trying-to-understand-how-logstash-redis-input-plugin-works/313042/3 "2022-08-26T20:38:07Z")

</div>

@Badger Thank you so much for your reply. This is clear now. I have another query if you can answer please that would be great. We are saving log files on Redis server with the following name conventions:

**911810C4B60D28180721B9C20CD0108D\_20220825\_06\_caa\_001.log.gz**  
**911810C4B60D28180721B9C20CD0108D\_20220825\_06\_caa\_002.log.gz**

Now, I wanted to know whether Redis stores the compressed files as it is (against a key, probably?)? And if so, then does Logstash reads each file at a time and pushes the logs to elasticsearch after parsing?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [August 26, 2022, 8:54pm UTC](https://discuss.elastic.co/t/trying-to-understand-how-logstash-redis-input-plugin-works/313042/4 "2022-08-26T20:54:56Z")

</div>

I have never actually used redis so I cannot answer that.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 23, 2022, 8:55pm UTC](https://discuss.elastic.co/t/trying-to-understand-how-logstash-redis-input-plugin-works/313042/5 "2022-09-23T20:55:39Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
