Skip to main content

probe.tcp

TCP probing checks whether a TCP port on a host is reachable by attempting a TCP connect and recording connect success and timing.

Arguments

You can use the following arguments with probe.tcp:

NameTypeDescriptionDefaultRequired
scrape_intervaldurationInterval at which targets should be probed.1mno
targetslist(object)List of TCP targets to probe. See target arguments below.no
target_fromreferenceReference to a discovery configuration to load targets from.no
forward_tolist(reference)List of exporter references to send metrics to.yes

Target Arguments

The TCP target object expects the following fields:

NameTypeDescriptionDefaultRequired
targetstringA target string in the form host:port, ip:port or fqdn:port. The probe will attempt a TCP connect to this endpoint.yes
timeout_secintegerTimeout in seconds for the TCP connect attempt.15no
labelsmap(string)Labels to attach to this target.no

Notes:

  • The target value must include a port. Targets without a port will fail the connect attempt (tests cover this edge case).
  • You can use hostnames (e.g. localhost:1234) or FQDNs — they will be resolved before connecting. Use .invalid domains in tests for guaranteed DNS failures.

Example

Plain text configuration

probe "tcp" "service_tcp" {
scrape_interval = "30s"
targets = [
{
target = "10.0.0.5:80"
timeout_sec = 5
labels = {
service = "backend"
env = "staging"
}
}
]

forward_to = [exporter.otlp.otlp]
}

Hostname (FQDN) example

probe "tcp" "local_check" {
targets = [
{ target = "localhost:8080" }
]
forward_to = [exporter.prometheus.prom]
}

From discovery (file)

discovery "file" "tcp_targets" {
path = ["./targets/tcp.json"]
}

probe "tcp" "discovered" {
target_from = discovery.file.tcp_targets
forward_to = [exporter.otlp.otlp]
}

Resources

None yet.