Skip to content

Socket


The socket collector is used to collect UDP/TCP port information.

Configuration

Preconditions

UDP metrics require the operating system to have nc programs.

Info

The socket collector are suitable for collecting local network TCP/UDP service. For public network, Dialtesting is recommended. If the URLs point to localhost, please turn off the election flag(election: false).

Collector Configuration

Go to the conf.d/samples directory under the DataKit installation directory, copy socket.conf.sample and name it socket.conf. Examples are as follows:

[[inputs.socket]]
  ## Support TCP/UDP.
  ## If the quantity to be detected is too large, it is recommended to open more collectors
  dest_url = [
    "tcp://host:port",
    "udp://host:port",
  ]

  ## @param interval - number - optional - default: 30
  interval = "30s"

  ## @param interval - number - optional - default: 10
  tcp_timeout = "10s"

  ## @param interval - number - optional - default: 10
  udp_timeout = "10s"

  ## set false to disable election
  election = true

[inputs.socket.tags]
  # some_tag = "some_value"
  # more_tag = "some_other_value"

After configuration, restart DataKit.

The collector can now be turned on by ConfigMap Injection Collector Configuration.

In Kubernetes, the DataKit domain is datakit-service.datakit.svc, and the log sender can specify the DataKit domain as the receiver. Typically, only the UDP protocol is recommended for using the domain name, as the TCP protocol may encounter issues with missing context in multiline data.

Metric

For all of the following measurements, the proto/dest_host/dest_port global tag is appended by default, or other tags can be specified in the configuration by [inputs.socket.tags]:

 [inputs.socket.tags]
  # some_tag = "some_value"
  # more_tag = "some_other_value"
  # ...

tcp

Tags & Fields Description
dest_host
(tag)
Configured TCP destination domain name or IP address, such as www.google.com or 1.2.3.4.
dest_port
(tag)
Configured TCP destination port, such as 80.
proto
(tag)
Socket protocol. Always tcp for this measurement.
response_time TCP connection duration excluding DNS lookup time.
Type: int | (gauge)
Unit: time,μs
Tagged by: dest_host, dest_port, proto
response_time_with_dns TCP connection duration including DNS lookup time.
Type: int | (gauge)
Unit: time,μs
Tagged by: dest_host, dest_port, proto
success Socket probe result: 1 for success and -1 for failure.
Type: int | (gauge)
Unit: N/A
Tagged by: dest_host, dest_port, proto

udp

Tags & Fields Description
dest_host
(tag)
Configured UDP destination domain name or IP address.
dest_port
(tag)
Configured UDP destination port.
proto
(tag)
Socket protocol. Always udp for this measurement.
success Socket probe result: 1 for success and -1 for failure.
Type: int | (gauge)
Unit: N/A
Tagged by: dest_host, dest_port, proto

Feedback

Is this page helpful? ×