Chuyển đến nội dung chính

Mô tả

Probe connection đọc bảng connection của host (không mở connection mới) và đếm số entry match các filter được cấu hình. Hỗ trợ filter theo process, endpoint, protocol và state. Yêu cầu platform adapter ConnAdapter. Nếu dùng filter processName/processPath, cần quyền đọc /proc/[pid]/fd của process khác (root hoặc CAP_SYS_PTRACE).

Config fields

FieldTypeBắt buộcDefaultMô tả
typestringPhải là "connection"
namestringTên nhận diện cho probe (dùng trong message và log)
descriptionstringKhôngMô tả mục đích kiểm tra
processNamestringKhôngLọc theo tên process. Cần CAP_SYS_PTRACE trên Linux
processPathstringKhôngLọc theo đường dẫn executable. Cần CAP_SYS_PTRACE trên Linux
localAddressstringKhôngLọc theo local IP address
localPortintKhôngLọc theo local port
remoteAddressstringKhôngLọc theo remote IP address
remotePortintKhôngLọc theo remote port
protocolstringKhôngLọc theo protocol: "tcp" hoặc "udp"
statesstring[]KhôngLọc theo connection state (ví dụ ["ESTABLISHED", "LISTEN"])
minCountintKhông1Số connection tối thiểu. count < minCount → down
maxCountintKhôngSố connection tối đa. count > maxCount → warning

Metrics

MetricTypeUnitMô tả
vms.connection.statusstatusup, down hoặc warning
vms.connection.countgaugeSố connection match
vms.agent.permission_missinggaugeEmit khi processName/processPath được cấu hình nhưng thiếu CAP_SYS_PTRACE

Ví dụ config

Kiểm tra nginx có connection tới DB:
{
  "type": "connection",
  "name": "nginx-to-postgres",
  "processName": "nginx",
  "remotePort": 5432,
  "states": ["ESTABLISHED"],
  "minCount": 1
}
Kiểm tra số connection LISTEN trên port:
{
  "type": "connection",
  "name": "app-listen-8080",
  "localPort": 8080,
  "states": ["LISTEN"],
  "minCount": 1,
  "maxCount": 1
}

Lưu ý

  • Probe không mở connection mới — chỉ đọc bảng connection hiện có của host.
  • Khi thiếu CAP_SYS_PTRACE, filter processName/processPath match 0 vì agent không thể attribute socket tới PID. Probe emit vms.agent.permission_missing{capability=CAP_SYS_PTRACE} để gap hiển thị.
  • Tất cả filter là AND logic — connection phải match tất cả filter được cấu hình.