# Save redis channel name inside document

**URL:** <https://discuss.elastic.co/t/save-redis-channel-name-inside-document/286633>\
**Category:** Logstash\
**Created:** [October 13, 2021, 2:05pm UTC](https://discuss.elastic.co/t/save-redis-channel-name-inside-document/286633 "2021-10-13T14:05:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Metehan\_Tagizade](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/metehan_tagizade/32/84916_2.png) [@Metehan\_Tagizade](https://discuss.elastic.co/u/Metehan_Tagizade)\
**Post date:** [October 13, 2021, 2:05pm UTC](https://discuss.elastic.co/t/save-redis-channel-name-inside-document/286633/1 "2021-10-13T14:05:59Z")

</div>

Hi,

I have logstash pipeline like:

```auto
input {

    redis {
        host=> "redis-endpoint.com"
        port => "6379"
        key => "*"
        data_type => "pattern_channel"
        batch_count => 100
        codec => "json"
    }

}

output {

    elasticsearch{
        hosts=>["localhost:9200"]
        index=>"channel_name"
    }

}

```

Inside input plugin I use **data\_type =\> "pattern\_channel"** and **key =\> "\*"**  
Is there a way to get channel name ?

I need to write document in an index which named with channel\_name.  
We have a lot of channel and i cannot set it with hard code

Thanks a lot

---

<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:** [October 13, 2021, 4:16pm UTC](https://discuss.elastic.co/t/save-redis-channel-name-inside-document/286633/2 "2021-10-13T16:16:11Z")

</div>

> [@Metehan\_Tagizade](#):
>
> Is there a way to get channel name ?

The [code](https://github.com/logstash-plugins/logstash-input-redis/blob/71d3ee5d75bd42458685e0ffd0520727d9ccaa21/lib/logstash/inputs/redis.rb#L163) adds the channel name as [@metadata][redis\_channel], so you can use a sprintf reference to that for the output index option.

---

<div class="post-metadata">

**Author:** ![Metehan\_Tagizade](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/metehan_tagizade/32/84916_2.png) [@Metehan\_Tagizade](https://discuss.elastic.co/u/Metehan_Tagizade)\
**Post date:** [October 14, 2021, 1:55pm UTC](https://discuss.elastic.co/t/save-redis-channel-name-inside-document/286633/3 "2021-10-14T13:55:54Z")

</div>

Solved my problem

Thank you so much

---

<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:** [November 11, 2021, 1:56pm UTC](https://discuss.elastic.co/t/save-redis-channel-name-inside-document/286633/4 "2021-11-11T13:56:49Z")

</div>

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