跳转至

Socket


采集 UDP/TCP 端口指标数据。

配置

前置条件

UDP 指标需要操作系统有 nc 程序

Info

socket 采集器适合做内网的 TCP/UDP 端口检测,对于公网服务,建议使用拨测功能。如果服务地址指向本机,请关闭采集器的选举(election: false)功能,否则会导致无效采集。

采集器配置

进入 DataKit 安装目录下的 conf.d/samples 目录,复制 socket.conf.sample 并命名为 socket.conf。示例如下:

[[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"

配置好后,重启 DataKit 即可。

目前可以通过 ConfigMap 方式注入采集器配置来开启采集器。

在 Kubernetes 环境下,DataKit 域名是 datakit-service.datakit.svc,日志发送端可以指定 DataKit 域名作为接收端。通常只推荐 UDP 协议使用域名,TCP 协议可能存在多行数据缺少上下文的情况。

指标

以下所有指标集,默认会追加 proto/dest_host/dest_port 全局 tag,也可以在配置中通过 [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

文档评价

文档内容是否对您有帮助? ×