Network Monitoring and Performance Questions
Network telemetry and performance operations: SNMP polling and traps (including counter wraparound and SNMPv3 access), NetFlow, sFlow and IPFIX flow export, sampling and its accuracy, streaming telemetry (gNMI), and eBPF or packet-capture telemetry; interface-level metrics (utilization, errors, discards, queue depth, microbursts), active synthetic probing alongside passive counters, link-flap detection, baselining and anomaly detection on network signals including elephant-flow spotting, network SLIs and SLOs, alerting, alert-storm suppression and NOC dashboards, telemetry pipeline design, storage, retention, downsampling and cardinality for network data (including securing the collection path and handling bursty remote sites), BGP and link-state monitoring including prefix hijack and route-leak detection, and network capacity monitoring, percentile utilization and bandwidth headroom planning. Also covers measuring and tuning network-level latency, jitter, packet loss and throughput (bufferbloat, queueing, TCP tuning for long paths). Excludes the generic metrics, logs and traces stack and alert design, the layered fault-isolation method and packet-capture troubleshooting, TCP and protocol fundamentals, application and CDN latency engineering, cloud VPC design and security detection.
A link between two routers flaps intermittently. How would you detect and alert on flapping reliably, avoid paging for every bounce, and tell a flap from a genuine outage?
Sample Answer
Direct answer
Treat "link is down" and "link is flapping" as two different alerts built from different questions. The rules below are written for Prometheus (a monitoring system that stores metrics as time series and evaluates alert expressions) and routed by Alertmanager (its companion that groups, deduplicates and delivers the notifications). An outage is one continuous state: the interface has been down for a set time (3 minutes here). A flap is a pattern: six or more state changes inside 15 minutes (three down-and-up bounces), whatever state it is in now. Page a human for the outage. Open a ticket for the flap, hold it open through the brief up periods so it does not resolve and re-fire every bounce, and suppress it while a real outage is already paging for the same interface. Then find the cause by comparing both ends, the error counters and the optics, because a flap is usually physical.
Detecting reliably: three signals, each with a blind spot
| Signal | What it gives | Blind spot |
|---|---|---|
| Polled state (ifOperStatus from the interface MIB, 1 = up, 2 = down, polled every 30 s) | Easy to alert on and graph | A bounce shorter than the poll interval can leave the state "up" at both polls |
| ifLastChange (the sysUpTime value when the interface entered its current state, RFC 2863) | Moves on every transition, so a short bounce still shows | Several bounces between two polls look like one change. It resets when the device reinitializes, giving one false change |
| Event stream: linkDown and linkUp traps, syslog, or a gNMI (gRPC Network Management Interface) ON_CHANGE subscription (the device sends an update only when a value changes) | One event per transition, with the device's own timestamp | Traps and syslog are commonly sent over UDP and can be lost, so reconcile with polling |
Use polled state for alerting, and the event stream as the exact count and timeline when you investigate. Do not treat an absence of polled changes as proof of a stable link.
Alert rules
groups:
- name: link-health
rules:
- alert: LinkDown
expr: ifOperStatus{ifAlias=~"UPLINK:.*"} == 2 and on (instance, ifIndex) ifAdminStatus == 1
for: 3m
labels:
severity: page
annotations:
summary: "{{ $labels.instance }} {{ $labels.ifName }} down for 3 minutes"
- alert: LinkFlapping
expr: changes(ifOperStatus{ifAlias=~"UPLINK:.*"}[15m]) >= 6
keep_firing_for: 20m
labels:
severity: ticket
annotations:
summary: "{{ $labels.instance }} {{ $labels.ifName }} changed state {{ $value }} times in 15 minutes"
changes()is a Prometheus function that returns the number of times a series' value changed in the window. Each down and each up counts as one, so 6 means three bounces.- The
for: 3mclause keeps an alert pending until the condition has held across 3 minutes of evaluations. A flap whose down periods are shorter than 3 minutes therefore never pages as an outage. keep_firing_for: 20mkeeps the flap alert firing after its condition last held, so the up phases between bounces do not resolve it and send another notification.ifAdminStatus == 1(administratively enabled) excludes ports an operator shut on purpose: a port that is administratively down also shows operational state down.and on (instance, ifIndex) ifAdminStatus == 1joins two series: theon (...)list says to pair samples that have the same device and interface index, so each interface's operational status is compared with its own admin status.- The
ifAlias=~"UPLINK:.*"selector assumes a naming convention that marks monitored links in the interface description. Use whatever your source of truth makes reliable.
Worked check: a 30-second poll series 1 1 2 1 1 1 2 1 1 2 1 1 (1 up, 2 down) holds one sample per 30 s, at t = 0, 30, 60 and so on to 330 s. The values change at t = 60, 90, 180, 210, 270 and 300 s, so the sixth change is at t = 300 s, and the series has six changes by the 5-minute mark, so LinkFlapping fires at 5 minutes with value 6. A link that goes down once and stays down has one change and never reaches the flap threshold, but fires LinkDown 3 minutes after it fell. A link whose state is 2 but whose ifAdminStatus is 2 fires neither.
Not paging for every bounce
route:
receiver: noc
group_by: [instance]
group_wait: 30s
group_interval: 5m
repeat_interval: 4h
routes:
- matchers: ['severity="page"']
receiver: pager
inhibit_rules:
- source_matchers: ['alertname="LinkDown"']
target_matchers: ['alertname="LinkFlapping"']
equal: [instance, ifName]
- Inhibition means a firing alert can silence a related one. Grouping by
instancemeans a line card failure that downs 24 links produces one notification for the device, not 24.group_wait(default 30 s) holds the first notification so related alerts arrive together,group_interval(default 5 minutes) spaces later updates for the same group, andrepeat_interval(default 4 hours) spaces reminders. - The inhibition rule suppresses
LinkFlappingfor an interface whileLinkDownis firing for the same instance and interface, because the outage page already covers it. - Only
severity="page"goes to the pager. The flap goes to the network operations center (NOC) queue as a ticket, so a link that bounces ten times overnight leaves one ticket, not ten pages.
Telling a flap from a genuine outage
| Observation | Flap | Outage |
|---|---|---|
| Operational state over 15 min | Repeated 1, 2, 1, 2 | One transition to 2 and staying there |
| Routing adjacencies (the neighbor sessions between routers) and traffic | Come and go, reconverge (recompute their routes) each time | Gone until fixed, traffic on the backup path |
| Error counters before the event | Often climbing (CRC, cyclic redundancy check, a checksum failure that signals a corrupted frame, and other input errors) | May be clean (a cut or power loss) |
| Alert | LinkFlapping, ticket | LinkDown, page |
Both can be true in sequence: a flapping link can end as an outage when the optic or cable finally fails, which is why the flap ticket matters.
Finding the cause, in order
- Compare both ends' logs. The same instant on both sides suggests the cable, patch panel (a rack of sockets where cables are cross-connected) or the optical path between them. One side logging link loss while the other stays up suggests that side's port or transceiver, or the far end's transmitter. The transceiver (also called the optic) is the pluggable module that turns the switch's signal into light or electrical signal on the cable, and a line card is a removable board holding a group of ports.
- Read the error counters. ifInErrors rising before each bounce points at signal quality (dirty fiber, damaged cable, bad optic).
- Read the optical power levels the transceiver reports (digital optical monitoring, DOM): transmit or receive power drifting near the limits explains flaps without any counter errors.
- Look at the timing. Intervals that repeat almost exactly (say every 40 seconds) suggest a protocol or timer, a negotiation loop or a power cycle. Random intervals suggest a physical fault.
- Change one thing. Swap the patch cable, then the optic, then move the port, and watch that the flap count over the next 15 minutes stays under the threshold.
Verify the fix
Run changes(ifOperStatus{...}[1h]) and expect 0 over a full hour, check the error counters are not rising, and let the keep_firing_for period elapse so the ticket clears on its own.
You are a staff network engineer with a limited budget. How do you prioritize investment across device monitoring, flow analytics, synthetic testing and packet capture, and how would you show it paid off?
Sample Answer
I would spend in this order: device monitoring, then synthetic testing, then flow analytics, then packet capture, and I would stage the spend rather than split it evenly.
1. Device monitoring first (SNMP or streaming counters, device state, syslog). It is the cheapest per unit of coverage, uses data the devices already produce, and answers the questions that hurt most: is it down, is it full, is it erroring. Software is largely open source (an SNMP exporter, a time-series database that stores numbers against timestamps, and an alert manager), so the spend is engineer time to get inventory, labels and alert quality right.
2. Synthetic testing second. Active probes (ICMP, DNS, HTTP, TCP; the open-source blackbox exporter supports these) from a few vantage points per site (places inside the network that the probes run from) measure what a user experiences, and catch failures that device counters cannot: an ISP brownout (the provider is degraded rather than fully down), a DNS fault, a path that is up but slow. Cost is small (a few lightweight probe agents per site).
3. Flow analytics third. NetFlow or IPFIX (standards in which routers and switches export one summary record per conversation: who talked to whom, on which ports, how many bytes) shows which prefixes (blocks of IP addresses, such as a customer network) and applications use bandwidth, which feeds capacity planning, cost decisions and security triage. The cost is collector storage and operations; mitigate it with sampling and 1-minute aggregates, and start with an open-source collector.
4. Packet capture last, and targeted. Capture is the only tool that proves protocol-level behavior (retransmissions, TCP resets, malformed frames), but storage is expensive and payload capture has privacy and legal exposure. Buy portable capture or a few taps (devices that copy the traffic on a link) at chokepoints only after the other three tools narrow the fault domain, and capture on demand rather than continuously.
If I had to split a notional 100 units of budget, I would say roughly 40 monitoring, 25 synthetic, 25 flow, 10 capture. The reasoning is about shape, not exact numbers: the largest share goes to the layer that covers every device and supplies the inventory and labels the other layers reuse; synthetic testing and flow analytics each need extra infrastructure that grows with the number of sites and links (probe agents, collector storage), so they get equal middle shares of 25. The order between them is a staging order, not a bigger share: probes need only a few agents and show user-visible failures within weeks, so they go live first, while flow needs collector sizing and sampling decisions first; capture gets a small reserve because it is bought for a few chokepoints and used on demand. Moving 5 units from monitoring to synthetic testing (35 versus 30) would keep the order; moving 8 or more would put a neighbour ahead of monitoring, so read the shares as bands rather than exact values, and moving 30 would be a different plan altogether. That is a judgement for an organisation with a typical mix, not a measured optimum.
What would change the order: a business that lives on SaaS and internet paths moves synthetic testing to first place; regulated or security-driven environments swap that staging so flow goes live first and gets the larger of the two shares; a history of intermittent physical-layer or protocol faults brings capture up.
Showing it paid off. Record a baseline from the last two quarters of incident tickets before spending: median time to detect (from fault start to first alert), median time to resolve, share of incidents first reported by users rather than monitoring, and count of "network is slow" tickets closed without a root cause. After rollout, track the same four measures with the same definitions. Example arithmetic with illustrative inputs (8 incidents a quarter; detection times in minutes):
import statistics as s
before = [38, 45, 22, 60, 50, 35, 41, 52]
after = [6, 9, 4, 15, 8, 11, 7, 12]
print("median before", s.median(before))
print("median after", s.median(after))
print("minutes saved per quarter", (s.median(before) - s.median(after)) * len(after))
Running it prints 43.0, 8.5 and 276.0. Eight incidents a quarter is a small sample, so a single quarter proves little: read the trend over two to three quarters and weigh the share of incidents first caught by monitoring, which moves with every incident. Report minutes of degraded service avoided and recurring incident classes removed; do not convert to money unless finance supplies the cost per minute.
How would you use eBPF to collect network telemetry from Linux hosts? What can you observe, what does it cost the host, and how do you get the data into an existing metrics and logging stack?
Sample Answer
Direct answer
eBPF (extended Berkeley Packet Filter) lets you load small, kernel-verified programs that run when the kernel hits a hook (a named point in the kernel where a program can be attached), such as a TCP connect, a retransmit, or a packet arriving at the network driver. For network telemetry you attach programs to the events you care about, aggregate in kernel memory (in a map, a table in kernel memory that both the program and a user-space agent can read), and have a user-space agent read the results and expose them to your existing stack: counters and histograms to Prometheus, discrete events to your log pipeline. It gives per-host, per-process visibility that SNMP and flow data cannot, at a cost that scales with how many events you attach to.
What you can observe
- Connection events with the owning process and container. The bcc (BPF Compiler Collection) tools show the idea:
tcpconnectprints one line for every active TCP connection,tcpacceptone line for every passive connection, andtcpretransone line for every TCP retransmit, with addresses and the kernel state of the connection. Because the hook is in the kernel you can attach the process or cgroup (control group, the kernel's container boundary) that owned the socket. For connect and accept the current task is normally the owner, so the current task's cgroup is the right label. Retransmits are different: they often fire from a timer or interrupt where the running task is unrelated (the PID 0 in thetcpretransoutput below is exactly that), so a program that counts retransmits per cgroup must read the cgroup from the socket itself (thebpf_sk_cgroup_idhelper returns a socket's cgroup v2 id) and not from the current task (bpf_get_current_cgroup_idreturns the cgroup of the task that is running). - Retransmits and drops per destination, which turn into "this host sees 2% retransmits toward that subnet" without a packet capture.
- Latency distributions (connect time, time between events) as histograms rather than averages.
- Dropped packets with a reason, by attaching where the kernel discards a packet.
- Limits: it sees what the host kernel sees. It cannot see the middle of the network, and encrypted payload stays encrypted (you see sizes and timing, not content).
What the tools print (addresses and process names are illustrative; the column layout is the one in the bcc documentation):
$ tcpconnect
PID COMM IP SADDR DADDR DPORT
1469 curl 4 10.201.219.236 54.245.105.25 80
$ tcpretrans
TIME PID IP LADDR:LPORT T> RADDR:RPORT STATE
01:55:05 0 4 10.153.223.157:22 R> 69.53.245.40:34619 ESTABLISHED
Reading it: each tcpconnect row is one outbound connection, naming the process (PID, COMM), the source and destination address and the destination port. Each tcpretrans row is one retransmitted segment: the local and remote address and port, R> meaning a retransmit, and the connection state at that moment. PID 0 means the kernel was running, not an application, when the retransmit fired. Many rows for the same remote address and port is one unhealthy connection, and rows spread over many remote addresses point at a wider path problem.
What it costs the host
- Overhead is per event. Attaching to a rare event (connect, retransmit) costs almost nothing in practice. Attaching a program to every packet on a 40G host adds work to every packet and can be measurable (ESTIMATE, depends on the program).
- Aggregate in the kernel (a map keyed by cgroup and destination subnet, incrementing counters or histogram buckets) instead of emitting one event per packet. Streaming every event to user space is where the CPU goes.
- Operational cost: you need a kernel with BTF (BPF Type Format, a description of the kernel's own data structures) so that CO-RE (compile once, run everywhere) programs can adapt to each kernel version without recompiling, and privileges (CAP_BPF and CAP_PERFMON, Linux capabilities that split root power into narrow permissions) for the agent. A first deployment on one kernel version needs the connection and retransmit hooks, one in-kernel counter and the exporter; BTF and CO-RE start to matter once the fleet runs several kernels. Programs are checked by the kernel verifier (a checker that proves the program terminates and only touches memory it is allowed to) before loading, so a bad program is rejected rather than crashing the host, but a correct program can still burn CPU. Test per kernel version in a canary and compare CPU with the probe on and off.
- Cardinality cost on the metrics side: labelling by client IP and port explodes the time series count. Label by service, cgroup or subnet.
Getting the data into the stack
- Metrics. Run
ebpf_exporter(Cloudflare's Prometheus exporter for eBPF). You describe counters and histograms in a YAML config, the exporter reads the kernel maps and converts binary keys to labels using decoders (a decoder turns a raw kernel value into readable text, for example a cgroup ID into its path or an address into a function name). Prometheus scrapes it like any exporter. The shape of a counter definition (the metric and label names here are illustrative; the fields and thecgroupdecoder are from the ebpf_exporter documentation):
metrics:
counters:
- name: tcp_retransmits_total
help: TCP retransmits by cgroup
labels:
- name: cgroup
size: 8
decoders:
- name: cgroup
Each entry names one counter, and each label says how many bytes of the map key to read (size) and how to decode them. A destination-subnet label is a second entry under labels with a decoder that matches how the program stores it.
2. Events. For things you want as log lines (every retransmit burst above a threshold, every drop with a reason), have the program write to a BPF ring buffer. The kernel documentation describes it as a buffer shared across CPUs that preserves ordering of events, which a per-CPU perf buffer (the older design, one separate buffer per CPU) does not. A small agent reads it, rate-limits, adds host and pod metadata, and ships JSON lines through the existing log shipper.
3. Correlate. Join on host and cgroup labels so a retransmit spike in the metrics can be traced to the log lines for the same pod.
Worked example
Goal: find which service is hurting from retransmits. Deploy a retransmit counter keyed by the socket's cgroup (not the running task's) and destination /24, export it as a counter, alert on the rate of change per service. Roll out to 5% of hosts first, compare node CPU for those hosts against the rest for a day, then widen. When the alert fires, run tcpretrans on one affected host to see the actual destinations and connection states.
Pitfalls
- Per-packet probes on high-rate interfaces without measuring overhead.
- Unbounded label cardinality (client IP as a label).
- Assuming one program works on every kernel: test the kernels you actually run.
- Treating host-side numbers as network truth: a host that is overloaded can show drops that the network did not cause.
How do you compute the 95th percentile of link utilization over a period, why do operators and carriers use it, and what does it hide? Show how you would get it from raw samples.
Sample Answer
Direct answer
Read the interface byte counter every 5 minutes, turn each pair of consecutive readings into an average rate, sort a month of those rates from highest to lowest, throw away the top 5%, and the highest remaining rate is the 95th percentile. In a 30-day month there are 8,640 five-minute samples, so 432 samples (exactly 36 hours) are discarded for free. Carriers use it for burstable billing (a plan where you commit to a base rate and are charged on how much you actually use) because it charges for the sustained rate while forgiving a bounded amount of bursting. It hides how large the discarded bursts were, how long a single burst lasted inside a 5-minute window, and it cannot be added across links (it is not additive: the percentile of a sum is not the sum of the percentiles).
From raw samples to a percentile
- Poll the counter. The raw sample is a cumulative octet (byte) count from the interface, read over SNMP (Simple Network Management Protocol, the standard polling protocol for device counters) as
ifHCOutOctetsorifHCInOctets, the 64-bit "high capacity" counters of the interface table. RFC 2863 requires 64-bit octet counters on interfaces faster than 20,000,000 bit/s and says a 32-bit counter can wrap in 34 seconds at 1 Gbit/s, so a 5-minute poll of a 32-bit counter on a gigabit port is simply wrong. - Difference and convert. rate = (reading_now - reading_before) x 8 / seconds_between_readings. Use the real timestamps of the two polls, not a nominal 300 s, so a late or missed poll does not distort the rate.
- Handle wrap and reset. Subtract modulo the counter size (2^64), meaning if the new reading is smaller than the old one because the counter rolled over, add 2^64 to the difference; that is what the
% WRAPin the code does. A device reboot resets the counter to near zero, which looks like a gigantic negative delta: discard that interval instead of billing it. - Sort and cut. Sort all rates, take the value at rank ceil(0.95 x n). This is the nearest-rank method; some billing systems interpolate between ranks, so the contract decides the exact method.
- Directions. Billing practice differs: take the higher of inbound and outbound per interval, or compute each direction's 95th percentile and bill the larger, or sum the two directions per interval. The contract names which one applies.
import math, random
INTERVAL = 300 # seconds between counter reads
N = 30 * 24 * 3600 // INTERVAL # 8640 samples in 30 days
WRAP = 2**64 # ifHCOutOctets is a 64-bit counter
def make_counter_reads(seed, base_mbps, burst_mbps, burst_every):
"""Cumulative octet counter read every 300 s; returns N+1 raw readings."""
rng = random.Random(seed)
reads, total = [], 10**12 # arbitrary starting value
reads.append(total)
for i in range(N):
mbps = max(1.0, rng.gauss(base_mbps, base_mbps * 0.15))
if i % burst_every == 0: # a 5-minute busy interval
mbps = burst_mbps
total = (total + int(mbps * 1e6 / 8 * INTERVAL)) % WRAP
reads.append(total)
return reads
def rates_mbps(reads):
out = []
for a, b in zip(reads, reads[1:]):
delta = (b - a) % WRAP # handles one wrap of the counter
out.append(delta * 8 / INTERVAL / 1e6)
return out
def p95_nearest_rank(values):
s = sorted(values)
k = math.ceil(0.95 * len(s)) # 1-based rank
return s[k - 1]
a = rates_mbps(make_counter_reads(1, 300, 900, 20))
b = rates_mbps(make_counter_reads(2, 200, 800, 33))
print("samples per 30 days:", len(a), "| top 5% discarded:", len(a) - math.ceil(0.95 * len(a)))
print("hours of traffic in the discarded 5%:", (len(a) - math.ceil(0.95 * len(a))) * INTERVAL / 3600)
for name, r in (("link A", a), ("link B", b)):
print(f"{name}: mean {sum(r)/len(r):7.1f} p95 {p95_nearest_rank(r):7.1f} max {max(r):7.1f} Mbit/s")
both = [x + y for x, y in zip(a, b)]
print(f"p95(A)+p95(B) = {p95_nearest_rank(a)+p95_nearest_rank(b):.1f} p95(A+B) = {p95_nearest_rank(both):.1f} Mbit/s")
# a wrap check: counter 1000 bytes below 2**64, then 5000 more bytes
before, after = WRAP - 1000, 5000 # 6000 octets sent across the wrap
print("wrap-safe delta:", (after - before) % WRAP, "(expected 6000)")
Output of exactly this code:
samples per 30 days: 8640 | top 5% discarded: 432
hours of traffic in the discarded 5%: 36.0
link A: mean 330.0 p95 453.0 max 900.0 Mbit/s
link B: mean 218.3 p95 261.5 max 800.0 Mbit/s
p95(A)+p95(B) = 714.5 p95(A+B) = 1087.2 Mbit/s
wrap-safe delta: 6000 (expected 6000)
Why operators and carriers use it
It is a billing compromise. A carrier sizes ports and upstream capacity for sustained load, and short spikes (a software update, a backup, a flash crowd) cost little. Charging on the 95th percentile means a customer can burst for up to 36 hours per 30 days without paying for it, while a customer running hot all day pays for that. It is also a stable number: one 5-minute spike cannot move it, which a maximum would.
What it hides
- Burst size. Link A above has a 900 Mbit/s burst in 5% of intervals and bills at 453 Mbit/s (mean 330, max 900). The 432 discarded samples are the whole story of the busiest hours and the bill says nothing about them.
- Burst duration inside a sample. Each sample is a 5-minute average. A 5-minute average of 400 Mbit/s on a 1,000 Mbit/s link is consistent with 20 seconds at full line rate and 280 seconds at about 357 Mbit/s (400 x 300 = 120,000 megabits in the window; the burst accounts for 20 x 1,000 = 20,000, so 120,000 - 20,000 = 100,000 remain; 100,000 / 280 s = 357). Queues overflow and packets drop in that 20 seconds while every graph looks calm.
- How the top 5% is distributed. 432 samples could be one 36-hour event or scattered five-minute bursts; the percentile is identical.
- No additivity. p95(A) + p95(B) = 714.5 Mbit/s but p95(A+B) = 1,087.2 Mbit/s. A's bursts (every 20th sample, 432 samples) and B's (every 33rd, 262 samples) overlap in 14 samples, so together 432 + 262 - 14 = 680 samples (7.9% of 8,640) are bursty, more than the 5% that gets discarded, and the combined percentile lands inside the burst population. Never sum percentiles to size a shared uplink.
Trade-offs and pitfalls
- For capacity planning, use the 95th percentile alongside the maximum and a shorter-interval peak, never alone. Billing wants a forgiving number; a capacity planner wants the busy-hour behaviour that the cut removes.
- A shorter polling interval raises the percentile for bursty traffic (less averaging), so a customer comparing numbers from a 1-minute tool with a 5-minute bill will see a mismatch that is not an error.
- Missing polls, unsynchronized clocks and counter resets are the usual causes of a disputed bill: keep the raw readings, not only the percentile.
Passive counters say the network is fine but users report slowness. How would you set up synthetic active checks to complement them: what to probe, how often, from where, and how to use the results?
Sample Answer
Direct answer
Build a ladder of probes (synthetic test requests run on a timer by the Prometheus blackbox exporter, a service that makes the probe and reports the result as metrics) that each test one more layer, run them from inside every branch toward the data center, and alert on the success ratio and latency percentile over a window, not on a single failed probe. A ladder of five probes at 15-second intervals from each branch (local gateway, hub router, DNS, TCP connect, HTTP request) costs 50 probes per second for 150 branches and pinpoints the failing layer. Use the results next to the counters: when passive data says healthy and active data says broken, the fault is on a layer or path the counters do not describe (a dependency, a policy, a provider path, a queue in one traffic class).
What to probe (the ladder)
| Probe | Module (blackbox exporter) | Question it answers | If it fails while the one above passes |
|---|---|---|---|
| Local gateway, ICMP (Internet Control Message Protocol) echo | icmp_probe | Is the branch LAN and gateway alive? | The switch, cabling, or gateway at the branch |
| Hub router, ICMP echo | icmp_probe | Is the WAN path up, and what are round-trip time (RTT) and loss? | WAN circuit, provider, or routing |
| DNS A-record query to the resolver | dns_a | Can the branch resolve the application name? | Resolver, or DNS traffic filtered |
| TCP connect to the application's virtual IP address (VIP, one address that fronts several servers) on port 443 | tcp_connect | Can a connection be opened? | Firewall policy, load balancer, or path for that port |
| HTTP GET of a health URL | http_2xx | Does the application answer correctly? | Application or TLS, not the network |
The Prometheus blackbox exporter provides the http, tcp, icmp, dns and grpc probers. The module names in the table are the ones defined in blackbox.yml below, and each is built on one prober type. Each probe returns probe_success (1 or 0) and probe_duration_seconds, and the ICMP prober returns probe_icmp_duration_seconds split by phase (resolve, setup, rtt). Use the rtt phase for latency.
How often
Detection time is roughly interval x number of failures you require, plus any for wait. At 15 seconds, the 5-minute window holds 20 probes, so the rule avg_over_time(probe_success[5m]) < 0.9 needs 3 failures (2 of 20 gives exactly 0.9 and does not fire), then a 2-minute for wait (the alert must stay true for that long before it fires). Step by step: with probes every 15 s and the outage starting at the first failed probe at t = 0, failures land at t = 0, 15 and 30 s. Two failures leave 18 of 20 successes, which is exactly 0.9 and does not fire; the third leaves 17 of 20 = 0.85, so the condition turns true at about t = 30 s. Adding the 2-minute wait gives about 150 s. Rule evaluation adds its own delay. Replaying this rule with promtool test rules, with probe_success going to 0 at a known time, the alert fired 150 s after the first failed probe when the rules were evaluated every 15 s, and 180 s after it with the default 1-minute evaluation_interval (the first evaluation after the condition turns true falls at 60 s, plus the 2-minute wait). Set the rule group's interval to 15 s for this rule, or accept the extra half minute. avg_over_time(probe_success[5m]) averages the 1s and 0s of the last 5 minutes into a success ratio. Probe less often (60 s) where an outage can wait, more often only for the few services where waiting 150 seconds to page is too slow. Cost is linear: 150 branches x 5 probes / 15 s = 50 probes per second.
From where
- Inside each branch, on a small probe host or container on the user VLAN, so the probe takes the same path and policy as users.
- From the hub toward branches, for the return direction (asymmetric routing and one-way faults).
- From a cloud vantage toward public services, to separate your WAN from the internet.
- At least two independent targets per layer (for example two hub routers, two DNS servers) so a dead target is not mistaken for a dead path.
Configuration (Prometheus scraping the blackbox exporter)
The exporter's modules (blackbox.yml): each block names a module and says which prober to use and how long to wait before counting a failure.
modules:
icmp_probe:
prober: icmp
timeout: 3s
tcp_connect:
prober: tcp
timeout: 3s
http_2xx:
prober: http
timeout: 5s
dns_a:
prober: dns
timeout: 3s
dns:
query_name: "app.example.com"
query_type: "A"
Prometheus then calls /probe?target=<target>&module=<module> on the exporter once per scrape. The relabel rules build that URL from the target's labels, in this order: the device address in __address__ is copied to __param_target (a label named __param_X becomes the URL parameter X, so this is target=); the label probe_module from the targets file is copied to __param_module, which becomes module= and picks the blackbox module; the address is also copied to instance so stored series are labelled with the probed device; and finally __address__ is overwritten with the exporter's own address, 127.0.0.1:9115, where the request is really sent. file_sd_configs (file-based service discovery) reads the target list from the YAML file below, which can change without restarting Prometheus:
scrape_configs:
- job_name: branch_probes
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /probe
file_sd_configs:
- files: [targets/branch-probes.yml]
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [probe_module]
target_label: __param_module
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 127.0.0.1:9115
# targets/branch-probes.yml (one entry per probe)
- targets: ['10.20.1.1']
labels: {site: branch-014, probe_module: icmp_probe, probe: lan_gateway}
- targets: ['10.0.0.1']
labels: {site: branch-014, probe_module: icmp_probe, probe: hub_icmp}
- targets: ['10.0.8.53:53']
labels: {site: branch-014, probe_module: dns_a, probe: app_dns}
- targets: ['10.0.8.10:443']
labels: {site: branch-014, probe_module: tcp_connect, probe: app_tcp}
- targets: ['https://app.example.com/health']
labels: {site: branch-014, probe_module: http_2xx, probe: app_http}
groups:
- name: synthetic-path
rules:
- alert: BranchProbeFailing
expr: avg_over_time(probe_success{probe="app_tcp"}[5m]) < 0.9
for: 2m
labels:
severity: page
- alert: BranchPathSlow
expr: quantile_over_time(0.95, probe_icmp_duration_seconds{probe="hub_icmp", phase="rtt"}[10m]) > 0.15
for: 5m
labels:
severity: ticket
quantile_over_time(0.95, ...) takes the 95th percentile (p95: 95 percent of the values are at or below it) of the last 10 minutes of round-trip times. The 150 ms threshold assumes a branch whose normal round trip to the hub is far below that. Set it from two weeks of the branch's own baseline plus a margin, not from a guess.
How to use the results
- Alert on ratio over time, as above, never on one failed probe.
- Set a service-level objective (SLO) on the same signal: for example 99.5 percent probe success per site per 30 days, an error budget (the amount of failure the objective permits) of 43,200 minutes x 0.5 percent = 216 minutes.
- Localize with the ladder and the counters:
| Active result | Passive result | Likely location |
|---|---|---|
| Hub ping slow or lossy | Uplink utilization near line rate | Congestion: look at queues and QoS (quality of service) |
| Hub ping slow or lossy | Uplink utilization low, counters clean | Provider path or a policing or queueing fault in one class |
| Ping fine, TCP connect fails | Flows show packets leaving but none returning | Firewall policy or asymmetric routing (replies take a different path than requests and are dropped by a stateful device) |
| TCP fine, HTTP fails or slow | Network counters clean | Application tier |
| All probes from one branch fail, other branches fine | That branch's uplink up | Branch gateway or provider circuit |
| All branches fail the same target | Hub counters clean | The target or hub-side service |
- Feed changes: run the same ladder before and after a change window and compare p95 RTT.
Pitfalls
- Probes measure the probe's class of traffic. If voice is queued separately, an ICMP probe may look fine while voice suffers: send probes marked with the same DSCP (differentiated services code point, the QoS marking in the IP header) as the traffic you care about. The blackbox exporter has no DSCP setting for its icmp, tcp or http probers, so apply the marking outside it (a firewall rule on the probe host that marks the exporter's outgoing packets) or use a probe tool that sets DSCP itself.
- Do not alert on every probe type at page severity. Page on the TCP probe, ticket on latency, and use the others for diagnosis.
- A probe host that is itself unhealthy produces false outages. Alert on the probe host's own metrics and on a probe that checks something known good.
Unlock Full Question Bank
Get access to all Network Monitoring and Performance interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.