Multiple passwords for redis output on filebeat


(Aboullaite Mohammed) #1

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:

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 ?!


(Adrian Serrano) #2

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.

Otherwise, feel free to submit a Feature Request in the Beats repository


(Aboullaite Mohammed) #3

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:

// 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)
    }

(Adrian Serrano) #4

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.


(Aboullaite Mohammed) #5

Done: https://github.com/elastic/beats/pull/5891

Thanks :wink:


(system) #6

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