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/socket 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
Tag Description
dest_host TCP domain or host, such as wwww.google.com, 1.2.3.4
dest_port TCP port, such as 80
proto Protocol, const to be tcp
  • Metrics
Metric Description
response_time TCP connection time(without DNS query time)
Type: int
Unit: time,μs
response_time_with_dns TCP connection time(with DNS query time)
Type: int
Unit: time,μs
success 1: success/-1: failed
Type: int
Unit: N/A

udp

  • Tags
Tag Description
dest_host UDP host
dest_port UDP port
proto Protocol, const to be udp
  • Metrics
Metric Description
success 1: success/-1: failed
Type: int
Unit: N/A

Feedback

Is this page helpful? ×