uber-archive / statsrelay

A consistent-hashing relay for statsd and carbon metrics
Other
101 stars 28 forks source link

Question: statsrelay support UDP? #70

Closed keyboardfann closed 7 years ago

keyboardfann commented 7 years ago

Hello All, Does statsrelay support UDP protocol? Here is my flow , metrics -> LVS -> statsrelay -> telegraf statsd udp input plugin.

statsrelay.conf

statsd:
  bind: 10.62.4.158:12001
  tcp_cork: false
  validate: true
  shard_map:
    0: 10.62.4.158:12100

telegraf statsd plugin listen on UDP 12100

ss -tunlp |grep 12100
udp    UNCONN     0      0      10.62.4.158:12100                 *:* 

run statsrelay

[root@tng1396 ~]# /usr/local/bin/statsrelay -c statsrelay.conf 
ERROR: tcpclient[10.62.4.158/12100/tcp]: Connect failed: Connection refused
JeremyGrosser commented 7 years ago

No, statsrelay only supports TCP for connecting to backends.

JeremyGrosser commented 7 years ago

Oh, I might be wrong about that... Just reading the code, I think if you do "0:10.62.4.158:12100:udp" in the shard map, it'll work.

keyboardfann commented 7 years ago

Dear @JeremyGrosser , Thank you for answer the question. I add udp to config and start statsrelay , statsrelay show Unexpectedly received zero-length UDP payload.

statsrelay.conf

statsd:
  bind: 10.62.4.158:12001
  tcp_cork: false
  validate: true
  shard_map:
    0: 10.62.4.158:12100:udp

start statsrelay

/usr/local/bin/statsrelay -c statsrelay.conf 
ERROR: stats: Unexpectedly received zero-length UDP payload.
ERROR: stats: Unexpectedly received zero-length UDP payload.
ERROR: stats: Unexpectedly received zero-length UDP payload.
ERROR: stats: Unexpectedly received zero-length UDP payload.
ERROR: stats: Unexpectedly received zero-length UDP payload.
ERROR: stats: Unexpectedly received zero-length UDP payload.
keyboardfann commented 7 years ago

Dear @JeremyGrosser, Ok, I find the problem. The error is because I use keepalive + LVS , and keepalive will use script to check statsrelay port open or not , so cause the error. The udp statsrelay work fine. Thank you.

keepalived.conf

    real_server 10.62.4.158 12001 {
        weight 10
#        MISC_CHECK {
#            misc_path "/data01/check_udp.sh 10.62.4.158 12001"
#            misc_timeout 10
#        }
        }