statsd

package
v0.0.47 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2022 License: MIT Imports: 20 Imported by: 0

README

StatsD Input Plugin

Configuration

# Statsd Server
[[inputs.statsd]]
  instance_id = "" # unique instance identifier (REQUIRED)
  
  ## Protocol, must be "tcp", "udp4", "udp6" or "udp" (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"

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

  ## Parses extensions to statsd in the datadog statsd format
  ## currently supports metrics and datadog tags.
  ## http://docs.datadoghq.com/guides/dogstatsd/
  datadog_extensions = true

  ## Statsd data translation templates, more info can be read here:
  ## https://github.com/circonus-labs/circonus-unified-agent/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

  ## Maximum socket buffer size in bytes, once the buffer fills up, metrics
  ## will start dropping.  Defaults to the OS default.
  # read_buffer_size = 65535

Description

The statsd plugin is a special type of plugin which runs a backgrounded statsd listener service while agent is running.

The format of the statsd messages was based on the format described in the original etsy statsd implementation. In short, the agent statsd listener will accept:

  • Gauges

    • users.current.den001.myapp:32|g <- standard
    • users.current.den001.myapp:+10|g <- additive
    • users.current.den001.myapp:-10|g
  • Counters

    • deploys.test.myservice:1|c <- increments by 1
    • deploys.test.myservice:101|c <- increments by 101
    • deploys.test.myservice:1|c|@0.1 <- with sample rate, increments by 10
  • Sets

    • users.unique:101|s
    • users.unique:101|s
    • users.unique:102|s <- would result in a count of 2 for users.unique
  • Timings & Histograms

    • load.time:320|ms
    • load.time.nanoseconds:1|h
    • load.time:200|ms|@0.1 <- sampled 1/10 of the time

It is possible to omit repetitive names and merge individual stats into a single line by separating them with additional colons:

  • users.current.den001.myapp:32|g:+10|g:-10|g
  • deploys.test.myservice:1|c:101|c:1|c|@0.1
  • users.unique:101|s:101|s:102|s
  • load.time:320|ms:200|ms|@0.1

This also allows for mixed types in a single line:

  • foo:1|c:200|ms

The string foo:1|c:200|ms is internally split into two individual metrics foo:1|c and foo:200|ms which are added to the aggregator separately.

Measurements

Meta:

  • tags: metric_type=<gauge|set|counter|timing|histogram|text>

Outputted measurements will depend entirely on the measurements that the user sends, but here is a brief rundown of what you can expect to find from each metric type:

  • Gauges

    • Gauges are a constant data type. They are not subject to averaging, and they don’t change unless you change them. That is, once you set a gauge value, it will be a flat line on the graph until you change it again.
  • Counters

    • Counters are the most basic type. They are treated as a count of a type of event. They will continually increase unless you set delete_counters=true.
  • Sets

    • Sets count the number of unique values passed to a key. For example, you could count the number of users accessing your system using users:<user_id>|s. No matter how many times the same user_id is sent, the count will only increase by 1.
  • Timings & Histograms

    • Timers are meant to track how long something took. They are an invaluable tool for tracking application performance.

Plugin arguments

  • protocol string: Protocol used in listener - tcp or udp options

  • max_tcp_connections []int: Maximum number of concurrent TCP connections to allow. Used when protocol is set to tcp.

  • tcp_keep_alive boolean: Enable TCP keep alive probes

  • tcp_keep_alive_period internal.Duration: Specifies the keep-alive period for an active network connection

  • service_address string: Address to listen for statsd UDP packets on

  • allowed_pending_messages integer: Number of messages allowed to queue up waiting to be processed. When this fills, messages will be dropped and logged.
  • templates []string: Templates for transforming statsd buckets into influx measurements and tags.

  • datadog_extensions boolean: Enable parsing of DataDog's extensions to dogstatsd format Note: events are ignored at this time.

Templates for Statsd bucket --> measurement name and tags

The plugin supports specifying templates for transforming statsd buckets into measurement names and tags. The templates have a measurement keyword, which can be used to specify parts of the bucket that are to be used in the measurement name. Other words in the template are used as tag names. For example, the following template:

templates = [
    "measurement.measurement.region"
]

would result in the following transformation:

cpu.load.us-west:100|g
=> cpu_load,region=us-west 100

Users can also filter the template to use based on the name of the bucket, using glob matching, like so:

templates = [
    "cpu.* measurement.measurement.region",
    "mem.* measurement.measurement.host"
]

which would result in the following transformation:

cpu.load.us-west:100|g
=> cpu_load,region=us-west 100

mem.cached.localhost:256|g
=> mem_cached,host=localhost 256

Consult the Template Patterns documentation for additional details.

Documentation

Index

Constants

View Source
const (
	MaxTCPConnections = 250
)

Variables

This section is empty.

Functions

This section is empty.

Types

type RunningStats

type RunningStats struct {
	PercLimit int
	// contains filtered or unexported fields
}

RunningStats calculates a running mean, variance, standard deviation, lower bound, upper bound, count, and can calculate estimated percentiles. It is based on the incremental algorithm described here:

https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance

func (*RunningStats) AddValue

func (rs *RunningStats) AddValue(v float64)

func (*RunningStats) Count

func (rs *RunningStats) Count() int64

func (*RunningStats) Lower

func (rs *RunningStats) Lower() float64

func (*RunningStats) Mean

func (rs *RunningStats) Mean() float64

func (*RunningStats) Percentile

func (rs *RunningStats) Percentile(n float64) float64

func (*RunningStats) Stddev

func (rs *RunningStats) Stddev() float64

func (*RunningStats) Sum

func (rs *RunningStats) Sum() float64

func (*RunningStats) Upper

func (rs *RunningStats) Upper() float64

func (*RunningStats) Variance

func (rs *RunningStats) Variance() float64

type Statsd

type Statsd struct {
	sync.Mutex
	UDPPacketsDrop     selfstat.Stat
	Log                cua.Logger
	ParseTimeNS        selfstat.Stat
	UDPBytesRecv       selfstat.Stat
	CurrentConnections selfstat.Stat
	UDPPacketsRecv     selfstat.Stat
	TCPBytesRecv       selfstat.Stat
	TCPPacketsRecv     selfstat.Stat
	MaxConnections     selfstat.Stat

	TotalConnections selfstat.Stat

	TraceMetrics *string `toml:"trace_metrics"` // direct metrics
	UDPlistener  *net.UDPConn
	TCPlistener  *net.TCPListener
	CheckTags    map[string]string // direct metrics - list of tags to add to check when created

	DebugAPI *bool `toml:"debug_api"` // direct metrics

	TCPKeepAlivePeriod *internal.Duration `toml:"tcp_keep_alive_period"`

	Broker                 string `toml:"broker"` // direct metrics
	MetricSeparator        string
	ServiceAddress         string
	Protocol               string `toml:"protocol"`
	InstanceID             string `toml:"instance_id"`
	Templates              []string
	UDPPacketSize          int `toml:"udp_packet_size"`
	MaxTCPConnections      int `toml:"max_tcp_connections"`
	AllowedPendingMessages int

	ReadBufferSize    int  `toml:"read_buffer_size"`
	DataDogExtensions bool `toml:"datadog_extensions"`
	TCPKeepAlive      bool `toml:"tcp_keep_alive"`
	// contains filtered or unexported fields
}

Statsd allows the importing of statsd and dogstatsd data.

func (*Statsd) Description

func (*Statsd) Description() string

func (*Statsd) Gather

func (s *Statsd) Gather(ctx context.Context, acc cua.Accumulator) error

func (*Statsd) SampleConfig

func (*Statsd) SampleConfig() string

func (*Statsd) Start

func (s *Statsd) Start(ctx context.Context, ac cua.Accumulator) error

func (*Statsd) Stop

func (s *Statsd) Stop()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL