Nightingale is an open-source cloud-native monitoring system. This article explains how to monitor ports with Nightingale.
Port monitoring is a typical method for process liveness detection. Compared to counting processes, port monitoring is more reliable, because a process may sometimes hang — its count remains normal, but the port can no longer respond properly.
Generally, port probing falls into three protocols:
- TCP protocol
- UDP protocol
- HTTP protocol
Depending on which protocol the service is listening on, the probing method differs.
TCP/UDP Protocols
TCP/UDP port monitoring is suitable for RPC-type services and can be implemented with Categraf’s net_response plugin.
The most important metric to focus on here is net_response_result_code. A value of 0 means everything is normal; a non-zero value indicates an exception, and different values represent different exception types.
- 0: Success
- 1: Timeout
- 2: ConnectionFailed
- 3: ReadFailed
- 4: StringMismatch
The relevant dashboards can be found in Nightingale’s Integration Center - Template Center.
HTTP Protocol
HTTP port probing is similar to TCP/UDP probing — Categraf also provides the http_response plugin. Compared to TCP/UDP, HTTP port monitoring can go a step further: in addition to probing port availability, it can also probe whether the HTTP response (status code, response body) matches expectations, and for HTTPS sites, it can probe certificate expiration time.
The metric used for alerts is http_response_result_code. As long as it equals 0, things are normal; if non-zero, something is wrong. Different values have different meanings:
Success = 0
ConnectionFailed = 1
Timeout = 2
DNSError = 3
AddressError = 4
BodyMismatch = 5
CodeMismatch = 6
http_response_cert_expire_timestamp is the certificate expiration timestamp. http_response_cert_expire_timestamp - time() indicates how long until the certificate expires, in seconds.
The relevant dashboards can be found in Nightingale’s Integration Center - Template Center.
Common Questions
Q1: What are the methods for port monitoring?
A:
- Categraf
net_responseplugin: Periodically performs TCP / UDP probes against target ports and reports thenet_response_result_codemetric; - PLUS Synthetic Monitoring: Probes from multiple nodes for more comprehensive coverage.
Q2: Can I monitor HTTPS certificate expiration?
A: Yes. Categraf’s http_response plugin supports retrieving the remaining validity days of the TLS certificate — it reports the http_response_cert_expire_timestamp metric, allowing you to configure a 30-day warning alert.