Socket Listener Monitoring
Use This InfluxDB Integration for FreeThe Telegraf Socket Listener Input Plugin is a service input plugin that listens for messages from streaming protocols like TCP or unix as well as datagram protocols like UDP or unixgram.
The main benefit of using Unix sockets over common network protocols is the performance boost. There is less overhead, and two processes on the same host can exchange data via the kernel. Using network protocols like TCP or UDP will send data by looping it back through the network interface, which takes more time and resources. If you are primarily sending data locally, using the Socket Listener Telegraf Input Plugin is a good idea.
Why use the Socket Listener Telegraf Input Plugin?
The main reason you would want to use the socket listener plugin is that it gives you a ton of flexibility for how you send data to Telegraf. It supports all the most popular networking protocols and plain Unix sockets, which means you can write your data using pretty much any programming language that supports creating sockets. This makes the socket listener plugin great for quick testing and also long-term production solutions.
Once your data is being sent to Telegraf, you can output that data to a number of different datastores. While Telegraf works best with InfluxDB, you can also output to many other popular databases or configure Telegraf to store the metrics in multiple datastores at the same time.
How to monitor Socket Listener using the Telegraf plugin
Setting up the Socket Listener Telegraf Input Plugin is simple, but also has a ton of available options to make it highly flexible for your use case:
# Generic socket listener capable of handling multiple socket types. [[inputs.socket_listener]] ## URL to listen on # service_address = "tcp://:8094" # service_address = "tcp://127.0.0.1:http" # service_address = "tcp4://:8094" # service_address = "tcp6://:8094" # service_address = "tcp6://[2001:db8::1]:8094" # service_address = "udp://:8094" # service_address = "udp4://:8094" # service_address = "udp6://:8094" # service_address = "unix:///tmp/telegraf.sock" # service_address = "unixgram:///tmp/telegraf.sock" ## Change the file mode bits on unix sockets. These permissions may not be ## respected by some platforms, to safely restrict write permissions it is best ## to place the socket into a directory that has previously been created ## with the desired permissions. ## ex: socket_mode = "777" # socket_mode = "" ## Maximum number of concurrent connections. ## Only applies to stream sockets (e.g. TCP). ## 0 (default) is unlimited. # max_connections = 1024 ## Read timeout. ## Only applies to stream sockets (e.g. TCP). ## 0 (default) is unlimited. # read_timeout = "30s" ## Optional TLS configuration. ## Only applies to stream sockets (e.g. TCP). # tls_cert = "/etc/telegraf/cert.pem" # tls_key = "/etc/telegraf/key.pem" ## Enables client authentication if set. # tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"] ## Maximum socket buffer size (in bytes when no unit specified). ## For stream sockets, once the buffer fills up, the sender will start backing up. ## For datagram sockets, once the buffer fills up, metrics will start dropping. ## Defaults to the OS default. # read_buffer_size = "64KiB" ## Period between keep alive probes. ## Only applies to TCP sockets. ## 0 disables keep alive probes. ## Defaults to the OS configuration. # keep_alive_period = "5m" ## Data format to consume. ## Each data format has its own unique set of configuration options, read ## more about them here: ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md # data_format = "influx" ## Content encoding for message payloads, can be set to "gzip" to or ## "identity" to apply no encoding. # content_encoding = "identity"
The read_buffer_size
config option can be used to adjust the size of the socket buffer, but this number is limited by OS settings. On Linux, read_buffer_size
will default to rmem_default
and will be capped by rmem_max
. On BSD systems, read_buffer_size
is capped by maxsockbuf
, and there is no OS default setting.
For some OS-specific setup instructions and things to watch out for, click on the project URL button below.
Key Socket Listener metrics to use for monitoring
Because of the flexible nature of sockets, you can define what metrics are being sent through the Socket Listener Telegraf Input Plugin. This can be data sent from a simple script or a complex application.