# Multiple passwords for redis output on filebeat

**URL:** <https://discuss.elastic.co/t/multiple-passwords-for-redis-output-on-filebeat/111284>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [December 12, 2017, 9:31am UTC](https://discuss.elastic.co/t/multiple-passwords-for-redis-output-on-filebeat/111284 "2017-12-12T09:31:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aboullaite](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@aboullaite](https://discuss.elastic.co/u/aboullaite)\
**Post date:** [December 12, 2017, 9:31am UTC](https://discuss.elastic.co/t/multiple-passwords-for-redis-output-on-filebeat/111284/1 "2017-12-12T09:31:56Z")

</div>

Hello all,

I'm sending data collected by filebeats to 2 different redis, and I'm enabling load balancer! My config file look something like this:

```auto
output.redis:
 hosts:
  - IP1
  - IP2
 password: redis_password
 key: "filebeat"
 db: 0
 timeout: 5
 loadbalance: true

```

As far as I know, the password accepts only one value and not an array, but now if my 2 redis have different passwords, how I can set up different passwords ?!

---

<div class="post-metadata">

**Author:** ![adrisr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adrisr/32/25423_2.png) [@adrisr](https://discuss.elastic.co/u/adrisr)\
**Post date:** [December 12, 2017, 7:42pm UTC](https://discuss.elastic.co/t/multiple-passwords-for-redis-output-on-filebeat/111284/2 "2017-12-12T19:42:08Z")

</div>

Hi aboullaite,

Unfortunately, using different passwords for hosts in a load balancer is not supported by Redis output.

I suggest you switch to a better method of securing your connection to Redis, by using stunnel as shown in [this blog post](https://www.digitalocean.com/community/tutorials/how-to-encrypt-traffic-to-redis-with-stunnel-on-ubuntu-16-04).

Otherwise, feel free to submit a Feature Request in the [Beats repository](https://github.com/elastic/beats/issues)

---

<div class="post-metadata">

**Author:** ![aboullaite](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@aboullaite](https://discuss.elastic.co/u/aboullaite)\
**Post date:** [December 12, 2017, 10:16pm UTC](https://discuss.elastic.co/t/multiple-passwords-for-redis-output-on-filebeat/111284/3 "2017-12-12T22:16:16Z")

</div>

Thanks adrisr for your answer!

I have something in mind and I wanted your opinion first. Basicly I changed The `Password` type to array and added this snippet:

```auto
// Create a map containing host <--> password
pwdhosts := make(map[string]string)
    for p, password := range config.Password {
        pwdhosts[hosts[p]] = password
    }

    clients := make([]outputs.NetworkClient, len(hosts))
    for i, host := range hosts {
        enc, err := codec.CreateEncoder(beat, config.Codec)
        if err != nil {
            return outputs.Fail(err)
        }
        conn, err := transport.NewClient(transp, "tcp", host, config.Port)
        if err != nil {
            return outputs.Fail(err)
        }

        clients[i] = newClient(conn, observer, config.Timeout,
// Add password with each host
            pwdhosts[hosts[i]], config.Db, key, dataType, config.Index, enc)
    }

```

---

<div class="post-metadata">

**Author:** ![adrisr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adrisr/32/25423_2.png) [@adrisr](https://discuss.elastic.co/u/adrisr)\
**Post date:** [December 13, 2017, 2:45pm UTC](https://discuss.elastic.co/t/multiple-passwords-for-redis-output-on-filebeat/111284/4 "2017-12-13T14:45:36Z")

</div>

That is a good start. Please consider submitting a Pull Request once it's working for you.

I suggest you add some logic to have the current behavior if only one password is specified, as well as make sure it doesn't crash when there is a different number of hosts and passwords.

---

<div class="post-metadata">

**Author:** ![aboullaite](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@aboullaite](https://discuss.elastic.co/u/aboullaite)\
**Post date:** [December 15, 2017, 9:50am UTC](https://discuss.elastic.co/t/multiple-passwords-for-redis-output-on-filebeat/111284/5 "2017-12-15T09:50:46Z")

</div>

Done: [https://github.com/elastic/beats/pull/5891](https://github.com/elastic/beats/pull/5891)

Thanks 😉

---

<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:** [January 12, 2018, 9:50am UTC](https://discuss.elastic.co/t/multiple-passwords-for-redis-output-on-filebeat/111284/6 "2018-01-12T09:50:46Z")

</div>

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