[SOLVED] Telegraf + StatsD input - cannot open 8125 port


I’m trying to run Telegraf with inputs.statsd plugin. But after run Telegraf it doesn’t open UDP/TCP port (I tried both).

I proceeded:

  1. Generated new telegraf.conf file:
$ telegraf -sample-config -input-filter statsd -output-filter influxdb > /tmp/telegraf.conf
  1. Run Telegraf from command line:
$ sudo -u telegraf telegraf -config telegraf.conf                                          
2018-07-24T14:04:28Z I! Starting Telegraf v1.7.1
2018-07-24T14:04:28Z I! Loaded inputs: inputs.statsd
2018-07-24T14:04:28Z I! Loaded aggregators: 
2018-07-24T14:04:28Z I! Loaded processors: 
2018-07-24T14:04:28Z I! Loaded outputs: influxdb
2018-07-24T14:04:28Z I! Tags enabled: host=jenpockej
2018-07-24T14:04:28Z I! Agent Config: Interval:10s, Quiet:false, Hostname:"jenpockej", Flush Interval:10s 
2018-07-24T14:04:28Z I! Started the statsd service on :8125
2018-07-24T14:04:28Z I! Statsd UDP listener listening on:  [::]:8125
  1. I checked open ports and 8125 isn’t opened:
$ sudo ss -tlnp | cat      
State    Recv-Q    Send-Q        Local Address:Port        Peer Address:Port                                                                                    
LISTEN   0         128       *        users:(("ssh",pid=11019,fd=5))                                                 
LISTEN   0         128            *        users:(("sshd",pid=593,fd=3))                                                  
LISTEN   0         128        *        users:(("influxd",pid=27924,fd=3))                                             
LISTEN   0         5          *        users:(("cntlm",pid=2377,fd=4))                                                
LISTEN   0         128                       *:8086                   *:*        users:(("influxd",pid=27924,fd=6))                                             
LISTEN   0         128                    [::]:22                  [::]:*        users:(("sshd",pid=593,fd=4))  
$ telnet localhost 8125                
telnet: Unable to connect to remote host: Connection refused

My [[inputs.statsd]] definition:

# Statsd UDP/TCP Server
  ## Protocol, must be "tcp", "udp", "udp4" or "udp6" (default=udp)
  protocol = "udp"

  ## MaxTCPConnection - applicable when protocol is set to tcp (default=250)
  max_tcp_connections = 250 

  ## Enable TCP keep alive probes (default=false)
  tcp_keep_alive = false

  ## Specifies the keep-alive period for an active network connection.
  ## Only applies to TCP sockets and will be ignored if tcp_keep_alive is false.
  ## Defaults to the OS configuration.
  # tcp_keep_alive_period = "2h"

  ## Address and port to host UDP listener on
  service_address = ":8125"

  ## The following configuration options control when telegraf clears it's cache
  ## of previous values. If set to false, then telegraf will only clear it's
  ## cache when the daemon is restarted.
  ## Reset gauges every interval (default=true)
  delete_gauges = true
  ## Reset counters every interval (default=true)
  delete_counters = true
  ## Reset sets every interval (default=true)
  delete_sets = true
  ## Reset timings & histograms every interval (default=true)
  delete_timings = true

  ## Percentiles to calculate for timing & histogram stats
  percentiles = [90]

  ## separator to use between elements of a statsd metric
  metric_separator = "_" 

  ## Parses tags in the datadog statsd format
  ## http://docs.datadoghq.com/guides/dogstatsd/
  parse_data_dog_tags = false

  ## Statsd data translation templates, more info can be read here:
  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md#graphite
  # templates = [
  #     "cpu.* measurement*"
  # ] 

  ## Number of UDP messages allowed to queue up, once filled,
  ## the statsd server will start dropping packets
  allowed_pending_messages = 10000

  ## Number of timing/histogram values to track per-measurement in the
  ## calculation of percentiles. Raising this limit increases the accuracy
  ## of percentiles but also increases the memory usage and cpu time.
  percentile_limit = 1000

Where it is configured as a udp socket, you won’t see it with -tlnp add a -u (assuming it’s similar to netstat commands) similarly, you’ll have to use a different tool to connect as telnet is TCP.

1 Like

@glinton Thx for your answer. In fact I’m feeling like Eeyore that I missed option -u in my ss command. I didn’t know that telnet is not possible to use for UDP connection. Now it seems to run alright. :]

1 Like

[telegraf] Error running agent: starting input inputs.statsd: listen udp :8125: bind: address already in use

I have followed the below config

Agent options around collection interval, sizes, jitter and so on

interval = “10s”
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 1000000
collection_jitter = “0s”
flush_interval = “10s”
flush_jitter = “0s”
precision = “”
hostname = “”
omit_hostname = false

protocol = “udp”
service_address = “:8125”
tcp_keep_alive = false
metric_separator = “.”
datadog_extensions = true