How to calculate more than 1 percentile for statsd plugin?

telegraf

#1

I am trying to add more than 1 percentile value for the statsd plugin.

[[inputs.statsd]]
percentiles = [90]

I’ve confirmed that the above config works but when I try to add more percentile values, I get a parse error.

I’ve tried:

[[inputs.statsd]]
percentiles = [50 90]

[[inputs.statsd]]
percentiles = [50, 90]

What is the correct way to set the statsd config to calculate more percentiles?


#2

It looks like you are doing it right to me, what error do you get?


#4

Error is:

2018/11/29 15:16:47 I! Using config file: /etc/telegraf/config.ini
2018/11/29 15:16:47 E! Error parsing /etc/telegraf/config.ini, toml: line 89: parse error

All the other values are default values from github.

# Statsd UDP/TCP Server
[[inputs.statsd]]
  ## 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 = [50 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/TEMPLATE_PATTERN.md
  # 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

#5

You will want to use the second format with the comma:

[[inputs.statsd]]
  percentiles = [50, 90]

If that’s not working can you remove any sensitive strings from your config and upload the whole file?


#6

Thanks, it worked! I guess I was making the changes in my text editor but it just wasn’t getting applied to the config file. :woman_facepalming:t2: