search
数据采集 采集源配置 TCP/UDP 检测数据采集

TCP/UDP 检测数据采集

简介

检查 tcp/udp 的连接状态,上报到 dataflux 中

前置条件

配置

进入 DataKit 安装目录下的 conf.d/network 目录,参照其中的 net_response.conf.sample 编辑一个 net_response.conf 文件。示例如下:

# # Collect response time of a TCP or UDP connection
# [[inputs.net_response]]
#   ## Protocol, must be "tcp" or "udp"
#   ## NOTE: because the "udp" protocol does not respond to requests, it requires
#   ## a send/expect string pair (see below).
#   protocol = "tcp"
#   ## Server address (default localhost)
#   address = "localhost:80"
#
#   ## Set timeout
#   # timeout = "1s"
#
#   ## Set read timeout (only used if expecting a response)
#   # read_timeout = "1s"
#
#   ## The following options are required for UDP checks. For TCP, they are
#   ## optional. The plugin will send the given string to the server and then
#   ## expect to receive the given 'expect' string back.
#   ## string sent to the server
#   # send = "ssh"
#   ## expected string in answer
#   # expect = "ssh"
#
#   ## Uncomment to remove deprecated fields
#   # fielddrop = ["result_type", "string_found"]

配置好后,重启 DataKit 即可生效

采集指标

net_response

指标 描述 类型 单位 Tag
response_time 响应时间 float server, port, protocol, result
result_code success:0, timeout:1, connection_failed:2, read_failed:3, string_mismatch:4 int - server, port, protocol, result
result_type 连接状态 string - server, port, protocol, result