driskell / log-courier

The Log Courier Suite is a set of lightweight tools created to ship and process log files speedily and securely, with low resource usage, to Elasticsearch or Logstash instances.
Other
419 stars 107 forks source link

log-courier 2.x: how random is random? (no randomness) #287

Closed sysmonk closed 8 years ago

sysmonk commented 8 years ago

Testing log-courier 2.x, i'm always getting connected to the same server when used "method": "random"

Example:

# /usr/local/bin/log-courier-new -version
Log Courier version 2.0.0-beta1
# cat /etc/log-courier.dfw.conf 
{
        "general": {
                "spool timeout": 5,
                "spool size": 1024,
                "log level" : "debug",
                "log syslog" : true,
                "admin enabled": true,
                "admin listen address": "unix:/var/run/log-courier-admin.socket",
                "persist directory": "/var/run/"
        },
        "network": {
                "method": "random",
                "servers": [ "logstash1.example.com:9001", 
                                         "logstash2.example.com:9001", 
                                         "logstash3.example.com:9001", 
                                         "logstash4.example.com:9001" 
                                   ],
                "ssl ca": "/usr/local/share/logstash/logstash.crt",
                "timeout": 60,
                "reconnect": 20,
                "max pending payloads": 20
        },
        "includes": [
                "/etc/log-courier.d/*.conf"
        ]
}

# for I in `seq 1 10`; do echo '1' | /usr/local/bin/log-courier-new -config /etc/log-courier.dfw.conf -stdin 2>&1 | grep -i connect; done
2016/03/14 16:08:21.354477 [logstash2.example.com:9001] Attempting to connect to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:21.431771 [logstash2.example.com:9001] Connected to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:22.374744 [logstash2.example.com:9001] Attempting to connect to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:22.454923 [logstash2.example.com:9001] Connected to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:23.399924 [logstash2.example.com:9001] Attempting to connect to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:23.480157 [logstash2.example.com:9001] Connected to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:24.423730 [logstash2.example.com:9001] Attempting to connect to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:24.502736 [logstash2.example.com:9001] Connected to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:25.444479 [logstash2.example.com:9001] Attempting to connect to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:25.538145 [logstash2.example.com:9001] Connected to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:26.466211 [logstash2.example.com:9001] Attempting to connect to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:26.546332 [logstash2.example.com:9001] Connected to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:27.486451 [logstash2.example.com:9001] Attempting to connect to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:27.574253 [logstash2.example.com:9001] Connected to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:28.509576 [logstash2.example.com:9001] Attempting to connect to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:28.586410 [logstash2.example.com:9001] Connected to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:29.530740 [logstash2.example.com:9001] Attempting to connect to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:29.650203 [logstash2.example.com:9001] Connected to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:30.553568 [logstash2.example.com:9001] Attempting to connect to 192.168.0.177:9001 (logstash2.example.com)
2016/03/14 16:08:30.655978 [logstash2.example.com:9001] Connected to 192.168.0.177:9001 (logstash2.example.com)
driskell commented 8 years ago

Awesome thanks for all the testing!

Looks like on first connect it's not random. I'll get some tests written too as the method is now a single code unit.