← Kỹ sư mạng← Network Engineer
Kỹ sư mạngNetwork Engineer19 Th7, 2026Jul 19, 202622 phút đọc19 min read

Giám sát & ObservabilityMonitoring & Observability

Thuộc bộ kiến thức Network Engineer Roadmap.

Tổng quan

Bạn không thể vận hành thứ mà bạn không nhìn thấy. Network monitoring và observability biến một “hộp đen” gồm cáp, switch, router, firewall và các link thành một hệ thống mà bạn có thể suy luận về sức khỏe, hiệu năng và hành vi gần như theo thời gian thực. Monitoring trả lời những câu hỏi bạn đã biết trước (“link có up không? CPU của core switch bao nhiêu? VLAN đó dùng bao nhiêu bandwidth?”). Observability đi xa hơn: mục tiêu là giúp bạn trả lời cả những câu hỏi bạn chưa lường trước, bằng cách phơi bày telemetry giàu thông tin, high-cardinality để bạn có thể cắt lát và tương quan (correlate) sau đó.

Tại sao phải đầu tư vào việc này?

Có hai bộ môn kinh điển mà observability bao trùm:

Bộ mônCâu hỏiTín hiệu điển hình
Fault monitoringNó có up / có hỏng không?interface up/down, SNMP trap, syslog error, reachability (ICMP/BFD)
Performance monitoringNó có đủ nhanh / khỏe không?throughput, latency, jitter, loss, CPU/memory, queue drop, error

Ghi chú này ánh xạ mô hình “ba trụ cột” tổng quát của observability sang networking, rồi đi qua các công nghệ telemetry cốt lõi — SNMP, flow export (NetFlow/sFlow/IPFIX), syslog, và streaming telemetry (gNMI) — cùng các stack lưu trữ và trực quan hóa chúng (Prometheus/Grafana, và các nền tảng thương mại như Datadog, Dynatrace). Cuối cùng là alerting, baselining, SLI/SLO, và capacity planning. Để chẩn đoán ở mức packet xem ./15-tools-and-troubleshooting.md; về các protocol bạn đang theo dõi xem ./06-core-protocols.md; và về hành vi queueing/marking mà các metric này phản ánh xem ./13-traffic-management-and-qos.md.

Kiến thức nền tảng

Ba trụ cột, điều chỉnh cho networking

Thế giới software-observability nói về metrics, logs, và traces. Networking có các tương đương trực tiếp cộng thêm một trụ cột riêng:

Trụ cộtThế giới softwareTương đương trong networkingThu thập qua
MetricsCounter/gauge theo thời gianInterface counter, CPU/mem, latency, drop, số BGP peerSNMP polling, streaming telemetry, synthetic probe
LogsDòng log ứng dụngSyslog: link flap, thay đổi config, ACL deny, sự kiện authsyslog (RFC 5424)
TracesSpan của request phân tánPhân tích path/hop: traceroute, IP SLA, đo path chủ độngtraceroute, IP SLA, TWAMP, synthetic test
Flows (riêng của networking)Bản ghi theo từng phiên: ai nói với ai, bao nhiêu, port nàoNetFlow / sFlow / IPFIX

Flows là trụ cột riêng của networking. Một flow record tóm tắt toàn bộ một “cuộc hội thoại” (5-tuple + số byte/packet + timing), rẻ hơn nhiều so với bắt từng packet nhưng giàu thông tin hơn nhiều so với một gauge bandwidth.

Push vs pull

Thiết kế hiện đại kết hợp cả hai: pull metric cho sức khỏe steady-state, push event/telemetry cho thay đổi và dữ liệu phân giải cao.

Cadence, cardinality, và retention

Ba “núm vặn” định hình mọi hệ thống monitoring:

Khái niệm chính

SNMP (Simple Network Management Protocol)

SNMP là “con ngựa thồ” nhiều thập kỷ để poll trạng thái thiết bị. Dù đã lâu đời, nó vẫn là mẫu số chung thấp nhất được gần như mọi thiết bị managed hỗ trợ.

Kiến trúc

Các operation

PDUChiềuMục đích
GET / GETNEXT / GETBULKManager → AgentĐọc một/kế tiếp/nhiều object (GETBULK hiệu quả khi walk bảng)
SETManager → AgentGhi/đổi giá trị (hiếm khi bật — rủi ro bảo mật)
TRAPAgent → ManagerNotification tự phát, fire-and-forget (ví dụ linkDown)
INFORMAgent → ManagerGiống trap nhưng có acknowledge (đáng tin cậy)
RESPONSEAgent → ManagerTrả lời GET/SET

Polling hoạt động bằng cách manager phát GET/GETBULK lên một danh sách OID theo lịch (ví dụ mỗi 60 s). Để tính rate (bps) bạn poll một counter hai lần rồi chia delta cho khoảng thời gian. Chú ý counter wrap: counter 32-bit (ifInOctets) wrap rất nhanh trên link 10G+ — luôn dùng counter high-capacity 64-bit (ifHCInOctets, OID 1.3.6.1.2.1.31.1.1.1.6).

Version & bảo mật

VersionBảo mậtGhi chú
v1community string, plaintextcũ, chỉ counter 32-bit — tránh dùng
v2ccommunity string, plaintextphổ biến nhất thực tế; có GETBULK & counter 64-bit; không mã hóa
v3USM: authentication + privacytheo user, hỗ trợ noAuthNoPriv / authNoPriv / authPriv; nên dùng authPriv (SHA + AES)

Ưu tiên SNMPv3 authPriv ở mọi nơi thiết bị và NMS hỗ trợ; chỉ lùi về v2c trên management network cô lập.

Ví dụ — bật SNMP trên Cisco IOS (v2c read-only, rồi v3):

! SNMPv2c read-only, giới hạn bằng ACL chỉ cho NMS
access-list 99 permit host 10.0.0.10
snmp-server community R3adOnly-x8f2 RO 99
snmp-server location DC1-Row4-Rack7
snmp-server contact netops@example.com
snmp-server host 10.0.0.10 version 2c R3adOnly-x8f2

! SNMPv3 — group, view, user (authPriv, SHA + AES-128)
snmp-server view ALL iso included
snmp-server group MONgrp v3 priv read ALL
snmp-server user monitor MONgrp v3 auth sha S3cret-Auth-Pass priv aes 128 S3cret-Priv-Pass
snmp-server enable traps
snmp-server host 10.0.0.10 version 3 priv monitor

Truy vấn từ một collector Linux:

# v2c walk bảng interface
snmpwalk -v2c -c 'R3adOnly-x8f2' 10.0.0.1 IF-MIB::ifTable

# v3 authPriv GET một counter
snmpget -v3 -l authPriv -u monitor \
  -a SHA -A 'S3cret-Auth-Pass' \
  -x AES -X 'S3cret-Priv-Pass' \
  10.0.0.1 IF-MIB::ifHCInOctets.2

Flow-based monitoring — NetFlow, sFlow, IPFIX

Trong khi SNMP cho biết bao nhiêu traffic đi qua một interface, flow monitoring cho biết traffic đó là gì: source/destination IP, port, protocol, ToS/DSCP, AS number, số byte/packet, và timing. Đây là nền tảng cho phân tích traffic, billing, quyết định peering, và phát hiện bảo mật (DDoS, scanning, exfiltration).

Flow export hoạt động thế nào (NetFlow/IPFIX)

  1. Router/switch duy trì một flow cache, key theo định nghĩa flow (kinh điển là 5-tuple: src IP, dst IP, src port, dst port, protocol; cộng ingress interface, ToS).
  2. Packet cập nhật counter của entry cache khớp.
  3. Một flow bị expire và export khi nó kết thúc (TCP FIN/RST), idle (idle timeout), sống quá lâu (active timeout, ví dụ 60 s), hoặc cache đầy.
  4. Các flow đã expire được đóng gói vào datagram UDP và gửi tới một flow collector (ví dụ nfdump/nfsen, Elastiflow, ntopng, Kentik).

Sampling. Trên link tốc độ cao, theo dõi mọi flow rất tốn kém, nên thiết bị lấy mẫu 1-trên-N packet (ví dụ 1:1000). Sampling là bắt buộc khi scale nhưng nghĩa là bạn phải nhân ngược số liệu lên và mất khả năng thấy các flow rất nhỏ.

Template. NetFlow v9 và IPFIX dựa trên template: exporter gửi trước một template mô tả các field, rồi các data record tham chiếu tới nó. Điều này giúp mở rộng linh hoạt (khác NetFlow v5 cố định). IPFIX còn hỗ trợ field độ dài thay đổi và element riêng của doanh nghiệp (ví dụ URL, application ID).

sFlow hoạt động khác: thay vì flow cache nó làm packet sampling — lấy N byte đầu (header) của mỗi packet thứ N và gửi mẫu đó ngay lập tức, cộng thêm counter interface định kỳ. Việc này stateless trên thiết bị (rẻ, thân thiện hardware, real-time) nhưng mang tính thống kê chứ không phải kế toán đầy đủ mọi cuộc hội thoại.

So sánh:

Đặc điểmNetFlow v5NetFlow v9IPFIX (v10)sFlow
Nguồn gốcCiscoCiscoChuẩn IETF (RFC 7011)sFlow.org / RFC 3176
Mô hìnhflow cacheflow cacheflow cachepacket + counter sampling
Fieldcố địnhdựa templatetemplate, độ dài thay đổi, element doanh nghiệpmẫu packet header
Samplingtùy chọntùy chọntùy chọnbản chất (luôn sampled)
LayerL3/L4L3/L4 (+MPLS, IPv6)L2–L7L2–L7 (raw header)
State trên thiết bịcó (cache)không (stateless)
Real-timetrễ theo timeouttrễ theo timeouttrễ theo timeoutgần tức thời
Tính chuẩnđộc quyềnđộc quyền (cơ sở của IPFIX)mở, IETFchuẩn đa nhà cung cấp

Quy tắc ngón tay cái: dùng IPFIX/NetFlow v9 khi cần kế toán chính xác và field phong phú; dùng sFlow khi cần khả năng nhìn rẻ, real-time, dựa hardware trên nhiều port tốc độ cao.

Ví dụ — Flexible NetFlow (kiểu IPFIX) trên Cisco IOS:

flow record RECORD-v4
 match ipv4 source address
 match ipv4 destination address
 match transport source-port
 match transport destination-port
 match ipv4 protocol
 collect counter bytes
 collect counter packets
 collect interface input

flow exporter EXP-1
 destination 10.0.0.20
 transport udp 2055
 export-protocol ipfix
 template data timeout 60

flow monitor MON-1
 record RECORD-v4
 exporter EXP-1
 cache timeout active 60

interface GigabitEthernet0/1
 ip flow monitor MON-1 input
 ip flow monitor MON-1 output

Syslog và quản lý log

Syslog (RFC 5424, cũ hơn là RFC 3164) là chuẩn để ghi log sự kiện thiết bị: link flap, thay đổi adjacency OSPF/BGP, thay đổi config, ACL/firewall deny, sự kiện authentication, cảnh báo hardware. Log là bản tường thuật giải thích tại sao một metric thay đổi.

Severity level (0 = tệ nhất). Một mnemonic hữu ích: Every Awesome Cisco Engineer Will Need Ice-cream Daily.

LevelTừ khóaÝ nghĩa
0Emergencyhệ thống không dùng được
1Alertphải hành động ngay
2Criticaltình huống critical
3Errortình huống error (ví dụ interface error)
4Warningtình huống warning
5Noticebình thường nhưng đáng chú ý (thay đổi config)
6Informationalthông tin (link up)
7Debugthông điệp debug (nhiễu)

Facility phân loại nguồn (ví dụ local0local7, auth, kern). Một message kết hợp facility + severity thành một priority.

Gửi log tới một collector trung tâm — rsyslog/syslog-ng, một stack ELK/OpenSearch, Graylog, Loki, hoặc một SIEM (Splunk, Elastic Security) để correlate và lưu trữ. Tập trung hóa quan trọng vì một thiết bị crash sẽ mang theo log cục bộ của nó, và việc correlate xuyên thiết bị (một flap ở đây, một error ở kia) cần mọi thứ ở cùng một nơi.

Ví dụ — Cisco IOS gửi tới syslog server, có timestamp và lọc theo level:

service timestamps log datetime msec localtime show-timezone
logging host 10.0.0.30 transport udp port 514
logging trap informational      ! gửi severity 6 trở xuống (tệ hơn)
logging source-interface Loopback0
logging buffered 64000 debugging

Luôn đồng bộ clock bằng NTP trước — log không có timestamp chính xác, nhất quán thì gần như vô dụng cho việc correlate.

Streaming telemetry (model-driven, gNMI)

SNMP polling có giới hạn thực sự: phân giải thô (không thể poll hàng nghìn OID mỗi giây), overhead cao (mỗi object một request/response), và cấu trúc MIB cứng nhắc. Model-driven streaming telemetry là câu trả lời hiện đại.

Kết quả: phân giải dưới giây, CPU thiết bị thấp hơn cho mỗi data point, và một data model nhất quán. Thu thập bằng một telemetry pipeline — Telegraf (với input gNMI/cisco_telemetry), Cisco Pipeline, hoặc gnmic — đổ vào một TSDB (InfluxDB, Prometheus) cho Grafana.

Ví dụ — subscription gNMI OpenConfig trên Cisco IOS-XR (path dial-in), cùng lệnh gnmic subscribe:

! Phía thiết bị (IOS-XR) — bật gRPC/gNMI
grpc
 port 57400
 tls-mutual
!
telemetry model-driven
 sensor-group IFCOUNTERS
  sensor-path openconfig-interfaces:interfaces/interface/state/counters
# Phía collector — subscribe với sample interval 1s
gnmic -a 10.0.0.1:57400 --skip-verify -u admin -p '***' \
  subscribe --path "openconfig-interfaces:interfaces/interface/state/counters" \
  --mode stream --stream-mode sample --sample-interval 1s
Khía cạnhSNMP pollingStreaming telemetry (gNMI)
Mô hìnhpull / request-responsepush / subscribe
Phân giảithường 30 s – 5 phútdưới giây, hoặc on-change
Data schemaMIB/OIDYANG (OpenConfig / vendor)
Overheadcao (mỗi object)thấp (stream gộp)
EncodingBERProtobuf / JSON
Bảo mậtv3 USMgRPC + TLS
Phù hợp nhấthỗ trợ thiết bị rộng, legacyscale, phân giải cao, OS hiện đại

Metrics & time-series stack — Prometheus + Grafana

Chuẩn thực tế open-source để lưu trữ và trực quan hóa metric.

Ví dụ — Prometheus scrape SNMP exporter cho hai switch:

# prometheus.yml
scrape_configs:
  - job_name: 'snmp-switches'
    static_configs:
      - targets:
          - 10.0.0.1      # core-sw-1
          - 10.0.0.2      # core-sw-2
    metrics_path: /snmp
    params:
      module: [if_mib]          # module định nghĩa trong snmp.yml
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 127.0.0.1:9116   # host:port của snmp_exporter

  - job_name: 'node'
    static_configs:
      - targets: ['10.0.0.30:9100']    # node_exporter trên host collector

Ví dụ PromQL — throughput interface theo bit/giây và một error rate:

# Throughput vào (bps) mỗi interface, rate 5 phút
rate(ifHCInOctets[5m]) * 8

# Các interface có input-error rate đang tăng
rate(ifInErrors[5m]) > 0

Nền tảng observability thương mại

Stack open-source mạnh nhưng cần lắp ráp và vận hành. Các nền tảng SaaS thương mại đánh đổi chi phí lấy sự “chìa khóa trao tay”, khả năng correlate rộng, và hỗ trợ.

Nền tảngĐiểm mạnh cho networking
DatadogHợp nhất infra + app + Network Performance Monitoring (NPM) và Network Device Monitoring (NDM/SNMP); nạp flow; correlate mạnh giữa app ↔ network; hợp với tổ chức thiên về cloud, DevOps.
DynatraceRoot-cause dựa AI (Davis engine), topology tự động (Smartscape), network visibility hiểu ứng dụng; nghiêng về APM doanh nghiệp.
KhácSolarWinds NPM, Cisco ThousandEyes (khả năng nhìn Internet/path, reachability SaaS), Kentik (phân tích flow ở quy mô lớn), LogicMonitor, Auvik.

Chúng phù hợp nhất khi bạn coi trọng time-to-value, correlate xuyên miền (network ↔ application ↔ cloud), và không muốn tự vận hành pipeline; open source phù hợp khi bạn cần kiểm soát, model tùy biến, hoặc muốn tránh giá theo per-host/per-flow.

Packet analysis cho kiểm tra sâu

Metric, flow, và log cho biết rằng và đại khái cái gì; khi cần biết chính xác tại sao ở mức byte, hãy bắt packet. Wireshark/tshark và tcpdump decode các field protocol, phơi bày retransmission, frame lỗi, vấn đề TCP window, và TLS handshake. Đây là hình thức nhìn sâu nhất và tốn kém nhất — dùng có chọn lọc, kích hoạt bởi điều mà metric/flow đã báo. Được trình bày chi tiết trong ./15-tools-and-troubleshooting.md.

Alerting, baselining, SLI/SLO, và capacity planning

Baselining. Mạng có tính mùa vụ (giờ làm việc, backup ban đêm, cuối tháng). Một threshold tĩnh (“alert nếu >80% util”) tạo báo động giả và bỏ sót bất thường. Hãy thiết lập một baseline hành vi bình thường per-interface/per-hour, rồi alert khi lệch khỏi nó (anomaly detection). Baseline cũng định nghĩa thế nào là “khỏe” cho SLO.

Nguyên tắc alerting.

Ví dụ alert Prometheus:

groups:
  - name: network
    rules:
      - alert: InterfaceDown
        expr: ifOperStatus == 2 and ifAdminStatus == 1
        for: 2m
        labels: {severity: critical}
        annotations:
          summary: "Interface {{ $labels.ifName }} down trên {{ $labels.instance }}"

      - alert: HighLinkUtilization
        expr: (rate(ifHCInOctets[5m])*8 / ifHighSpeed / 1e6) > 0.85
        for: 10m
        labels: {severity: warning}
        annotations:
          summary: "Link >85% util trên {{ $labels.instance }} {{ $labels.ifName }}"

SLI / SLO cho mạng. Mượn thực hành SRE:

SLI mạng điển hình: availability (reachability qua synthetic probe/BFD), latency, jitter, loss, và throughput — đo bằng active probe (IP SLA, TWAMP, blackbox_exporter, ThousandEyes) chứ không chỉ counter thiết bị, để bạn đo path của người dùng.

Capacity planning. Dùng dữ liệu trend lưu dài để dự báo khi nào link, CPU, TCAM/FIB, hay NAT table sẽ cạn. Theo dõi utilization percentile 95 (metric billing của ngành cho transit), mô hình hóa tăng trưởng, và cấp phát trước khi vượt ~70–80% duy trì. Dữ liệu flow còn cho thấy ứng dụng hay peer nào thúc đẩy tăng trưởng, cấp thông tin cho quyết định peering và QoS (xem ./13-traffic-management-and-qos.md).

Bảng so sánh tool / kỹ thuật

Kỹ thuậtPhù hợp nhấtPhân giảiOverheadGhi chú
SNMP pollingmetric thiết bị rộng, health30 s–5 phúttrung bìnhhỗ trợ phổ quát; dùng v3, counter 64-bit
Streaming telemetry (gNMI)metric phân giải cao ở quy mô lớndưới giây / on-changethấpYANG/OpenConfig; chỉ OS hiện đại
NetFlow/IPFIXkế toán traffic, bảo mậttheo flow-timeouttrung bìnhai-nói-với-ai, field phong phú
sFlowreal-time, nhiều port nhanhgần tức thời (sampled)thấpstateless, thống kê
Syslogsự kiện, config/audit, faulttheo sự kiệnthấpcần NTP + store trung tâm
Synthetic probe (IP SLA/TWAMP/blackbox)SLO theo path người dùng (latency/loss)giâythấpchủ động, đo path chứ không phải box
Packet capture (Wireshark/tcpdump)root-cause sâumỗi packetcaochỉ dùng có chọn lọc

Best Practices

Tài liệu tham khảo

Part of the Network Engineer Roadmap knowledge base.

Overview

You cannot operate what you cannot see. Network monitoring and observability turn a black box of cables, switches, routers, firewalls, and links into a system whose health, performance, and behavior you can reason about in near real time. Monitoring answers the questions you already know to ask (“is the link up? what is the CPU on the core switch? how much bandwidth is that VLAN using?”). Observability goes further: it aims to let you answer questions you did not anticipate ahead of time, by exposing rich, high-cardinality telemetry that you can slice and correlate after the fact.

Why invest in this at all?

There are two classic disciplines that observability spans:

DisciplineQuestionTypical signals
Fault monitoringIs it up / broken?interface up/down, SNMP traps, syslog errors, reachability (ICMP/BFD)
Performance monitoringIs it fast / healthy enough?throughput, latency, jitter, loss, CPU/memory, queue drops, errors

This note maps the general “three pillars” of observability onto networking, then works through the core telemetry technologies — SNMP, flow export (NetFlow/sFlow/IPFIX), syslog, and streaming telemetry (gNMI) — and the stacks that store and visualize them (Prometheus/Grafana, and commercial platforms like Datadog and Dynatrace). It closes with alerting, baselining, SLIs/SLOs, and capacity planning. For hands-on packet-level diagnosis see ./15-tools-and-troubleshooting.md; for the protocols you are watching see ./06-core-protocols.md; and for the queueing/marking behavior these metrics reflect see ./13-traffic-management-and-qos.md.

Fundamentals

The three pillars, adapted to networking

The software-observability world talks about metrics, logs, and traces. Networking has direct analogs plus one extra pillar of its own:

PillarSoftware worldNetworking equivalentCollected via
MetricsCounters/gauges over timeInterface counters, CPU/mem, latency, drops, BGP peer countSNMP polling, streaming telemetry, synthetic probes
LogsApp log linesSyslog: link flaps, config changes, ACL denies, auth eventssyslog (RFC 5424)
TracesDistributed request spansPath/hop analysis: traceroute, IP SLA, active path measurementtraceroute, IP SLA, TWAMP, synthetic tests
Flows (networking-specific)Per-conversation records: who talked to whom, how much, on what portsNetFlow / sFlow / IPFIX

Flows are the pillar unique to networking. A single flow record summarizes an entire conversation (5-tuple + byte/packet counts + timing), which is far cheaper than capturing every packet but far richer than a bandwidth gauge.

Push vs pull

Modern designs blend both: pull metrics for steady-state health, push events/telemetry for change and high-resolution data.

Cadence, cardinality, and retention

Three knobs shape every monitoring system:

Key Concepts

SNMP (Simple Network Management Protocol)

SNMP is the decades-old workhorse for polling device state. Despite its age it remains the lowest-common-denominator supported by virtually every managed device.

Architecture

Operations

PDUDirectionPurpose
GET / GETNEXT / GETBULKManager → AgentRead one/next/many objects (GETBULK is efficient for walking tables)
SETManager → AgentWrite/change a value (rarely enabled — security risk)
TRAPAgent → ManagerUnsolicited, fire-and-forget notification (e.g., linkDown)
INFORMAgent → ManagerLike a trap but acknowledged (reliable)
RESPONSEAgent → ManagerReply to GET/SET

Polling works by the manager issuing GET/GETBULK against a list of OIDs on a schedule (e.g., every 60 s). To compute a rate (bps) you poll a counter twice and divide the delta by the interval. Watch for counter wrap: 32-bit counters (ifInOctets) wrap fast on 10G+ links — always use the 64-bit high-capacity counters (ifHCInOctets, OID 1.3.6.1.2.1.31.1.1.1.6).

Versions & security

VersionSecurityNotes
v1community string, plaintextlegacy, 32-bit counters only — avoid
v2ccommunity string, plaintextmost common in practice; GETBULK & 64-bit counters; no encryption
v3USM: authentication + privacyuser-based, supports noAuthNoPriv / authNoPriv / authPriv; use authPriv (SHA + AES)

Prefer SNMPv3 authPriv wherever the device and NMS support it; fall back to v2c only on isolated management networks.

Example — enabling SNMP on Cisco IOS (v2c read-only, then v3):

! SNMPv2c read-only, restricted by ACL to the NMS
access-list 99 permit host 10.0.0.10
snmp-server community R3adOnly-x8f2 RO 99
snmp-server location DC1-Row4-Rack7
snmp-server contact netops@example.com
snmp-server host 10.0.0.10 version 2c R3adOnly-x8f2

! SNMPv3 — group, view, user (authPriv, SHA + AES-128)
snmp-server view ALL iso included
snmp-server group MONgrp v3 priv read ALL
snmp-server user monitor MONgrp v3 auth sha S3cret-Auth-Pass priv aes 128 S3cret-Priv-Pass
snmp-server enable traps
snmp-server host 10.0.0.10 version 3 priv monitor

Query it from a Linux collector:

# v2c walk of the interface table
snmpwalk -v2c -c 'R3adOnly-x8f2' 10.0.0.1 IF-MIB::ifTable

# v3 authPriv GET of a single counter
snmpget -v3 -l authPriv -u monitor \
  -a SHA -A 'S3cret-Auth-Pass' \
  -x AES -X 'S3cret-Priv-Pass' \
  10.0.0.1 IF-MIB::ifHCInOctets.2

Flow-based monitoring — NetFlow, sFlow, IPFIX

Where SNMP tells you how much traffic crossed an interface, flow monitoring tells you what that traffic was: source/destination IPs, ports, protocol, ToS/DSCP, AS numbers, byte/packet counts, and timing. This is the foundation of traffic analysis, billing, peering decisions, and security detection (DDoS, scanning, exfiltration).

How flow export works (NetFlow/IPFIX)

  1. The router/switch maintains a flow cache, keyed by the flow definition (classically the 5-tuple: src IP, dst IP, src port, dst port, protocol; plus ingress interface, ToS).
  2. Packets update the matching cache entry’s counters.
  3. A flow is expired and exported when it ends (TCP FIN/RST), goes idle (idle timeout), lives too long (active timeout, e.g., 60 s), or the cache fills.
  4. Expired flows are packed into UDP datagrams and sent to a flow collector (e.g., nfdump/nfsen, Elastiflow, ntopng, Kentik).

Sampling. On high-speed links, tracking every flow is expensive, so devices sample 1-in-N packets (e.g., 1:1000). Sampling is essential at scale but means you must scale counts back up and lose visibility into very small flows.

Templates. NetFlow v9 and IPFIX are template-based: the exporter first sends a template describing the fields, then data records referencing it. This makes them extensible (unlike fixed NetFlow v5). IPFIX also supports variable-length fields and enterprise-specific elements (e.g., URLs, application IDs).

sFlow works differently: instead of a flow cache it does packet sampling — it grabs the first N bytes (header) of every Nth packet and ships that sample immediately, plus periodic interface counters. This is stateless on the device (cheap, hardware-friendly, real-time) but statistical rather than a full accounting of every conversation.

Comparison:

FeatureNetFlow v5NetFlow v9IPFIX (v10)sFlow
OriginCiscoCiscoIETF standard (RFC 7011)sFlow.org / RFC 3176
Modelflow cacheflow cacheflow cachepacket + counter sampling
Fieldsfixedtemplate-basedtemplate, variable-length, enterprise elementspacket header samples
Samplingoptionaloptionaloptionalinherent (always sampled)
LayersL3/L4L3/L4 (+MPLS, IPv6)L2–L7L2–L7 (raw header)
State on deviceyes (cache)yesyesno (stateless)
Real-timedelayed by timeoutsdelayed by timeoutsdelayed by timeoutsnear-instant
Standardproprietaryproprietary (basis of IPFIX)open IETFmulti-vendor standard

Rule of thumb: IPFIX/NetFlow v9 when you want accurate accounting and rich fields; sFlow when you want cheap, real-time, hardware-based visibility across many high-speed ports.

Example — Flexible NetFlow (IPFIX-style) on Cisco IOS:

flow record RECORD-v4
 match ipv4 source address
 match ipv4 destination address
 match transport source-port
 match transport destination-port
 match ipv4 protocol
 collect counter bytes
 collect counter packets
 collect interface input

flow exporter EXP-1
 destination 10.0.0.20
 transport udp 2055
 export-protocol ipfix
 template data timeout 60

flow monitor MON-1
 record RECORD-v4
 exporter EXP-1
 cache timeout active 60

interface GigabitEthernet0/1
 ip flow monitor MON-1 input
 ip flow monitor MON-1 output

Syslog and log management

Syslog (RFC 5424, older RFC 3164) is the standard for device event logging: link flaps, OSPF/BGP adjacency changes, config changes, ACL/firewall denies, authentication events, hardware alarms. Logs are the narrative record that explains why a metric moved.

Severity levels (0 = worst). A useful mnemonic: Every Awesome Cisco Engineer Will Need Ice-cream Daily.

LevelKeywordMeaning
0Emergencysystem unusable
1Alertact immediately
2Criticalcritical condition
3Errorerror condition (e.g., interface errors)
4Warningwarning condition
5Noticenormal but significant (config change)
6Informationalinformational (link up)
7Debugdebug messages (noisy)

Facilities categorize the source (e.g., local0local7, auth, kern). A message combines facility + severity into a priority.

Ship logs to a central collector — rsyslog/syslog-ng, an ELK/OpenSearch stack, Graylog, Loki, or a SIEM (Splunk, Elastic Security) for correlation and retention. Centralization matters because a device that crashes takes its local logs with it, and cross-device correlation (a flap here, an error there) needs everything in one place.

Example — Cisco IOS to a syslog server, timestamped and level-filtered:

service timestamps log datetime msec localtime show-timezone
logging host 10.0.0.30 transport udp port 514
logging trap informational      ! send severity 6 and worse
logging source-interface Loopback0
logging buffered 64000 debugging

Always sync clocks with NTP first — logs without accurate, consistent timestamps are nearly useless for correlation.

Streaming telemetry (model-driven, gNMI)

SNMP polling has real limits: coarse resolution (you can’t poll thousands of OIDs every second), high overhead (request/response per object), and rigid MIB structures. Model-driven streaming telemetry is the modern answer.

Result: sub-second resolution, lower device CPU per data point, and a consistent data model. Collect with a telemetry pipeline — Telegraf (with the gNMI/cisco_telemetry inputs), Cisco’s Pipeline, or gnmic — landing into a TSDB (InfluxDB, Prometheus) for Grafana.

Example — OpenConfig gNMI subscription on Cisco IOS-XR (dial-in path), plus a gnmic subscribe:

! Device side (IOS-XR) — enable gRPC/gNMI
grpc
 port 57400
 tls-mutual
!
telemetry model-driven
 sensor-group IFCOUNTERS
  sensor-path openconfig-interfaces:interfaces/interface/state/counters
# Collector side — subscribe at 1s sample interval
gnmic -a 10.0.0.1:57400 --skip-verify -u admin -p '***' \
  subscribe --path "openconfig-interfaces:interfaces/interface/state/counters" \
  --mode stream --stream-mode sample --sample-interval 1s
AspectSNMP pollingStreaming telemetry (gNMI)
Modelpull / request-responsepush / subscribe
Resolution30 s – 5 min typicalsub-second, or on-change
Data schemaMIB/OIDYANG (OpenConfig / vendor)
Overheadhigh (per-object)low (batched stream)
EncodingBERProtobuf / JSON
Securityv3 USMgRPC + TLS
Best forbroad device support, legacyscale, high resolution, modern OS

Metrics & time-series stack — Prometheus + Grafana

The open-source de-facto standard for storing and visualizing metrics.

Example — Prometheus scraping the SNMP exporter for two switches:

# prometheus.yml
scrape_configs:
  - job_name: 'snmp-switches'
    static_configs:
      - targets:
          - 10.0.0.1      # core-sw-1
          - 10.0.0.2      # core-sw-2
    metrics_path: /snmp
    params:
      module: [if_mib]          # module defined in snmp.yml
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 127.0.0.1:9116   # the snmp_exporter host:port

  - job_name: 'node'
    static_configs:
      - targets: ['10.0.0.30:9100']    # collector host node_exporter

Example PromQL — interface throughput in bits/sec and an error rate:

# Ingress throughput (bps) per interface, 5-min rate
rate(ifHCInOctets[5m]) * 8

# Interfaces with a rising input-error rate
rate(ifInErrors[5m]) > 0

Commercial observability platforms

Open-source stacks are powerful but need assembly and operation. Commercial SaaS platforms trade cost for turnkey breadth, correlation, and support.

PlatformSweet spot for networking
DatadogUnified infra + app + Network Performance Monitoring (NPM) and Network Device Monitoring (NDM/SNMP); flow ingestion; strong correlation across app ↔ network; good for cloud-heavy, DevOps-oriented orgs.
DynatraceAI-driven root-cause (Davis engine), automatic topology (Smartscape), application-aware network visibility; enterprise APM leaning.
OthersSolarWinds NPM, Cisco ThousandEyes (Internet/path visibility, SaaS reachability), Kentik (flow analytics at scale), LogicMonitor, Auvik.

They fit best when you value time-to-value, cross-domain correlation (network ↔ application ↔ cloud), and don’t want to run the pipeline yourself; open source fits when you need control, custom models, or want to avoid per-host/per-flow pricing.

Packet analysis for deep inspection

Metrics, flows, and logs tell you that and roughly what; when you need to know exactly why at the byte level, capture packets. Wireshark/tshark and tcpdump decode protocol fields, expose retransmissions, malformed frames, TCP window issues, and TLS handshakes. This is the deepest and most expensive form of visibility — use it surgically, triggered by what your metrics/flows flagged. Covered in depth in ./15-tools-and-troubleshooting.md.

Alerting, baselining, SLIs/SLOs, and capacity planning

Baselining. Networks are seasonal (business hours, backups at night, month-end). A static threshold (“alert if >80% util”) produces false alarms and misses anomalies. Establish a baseline of normal per-interface/per-hour behavior, then alert on deviation from it (anomaly detection). Baselines also define what “healthy” means for SLOs.

Alerting principles.

Example Prometheus alert:

groups:
  - name: network
    rules:
      - alert: InterfaceDown
        expr: ifOperStatus == 2 and ifAdminStatus == 1
        for: 2m
        labels: {severity: critical}
        annotations:
          summary: "Interface {{ $labels.ifName }} down on {{ $labels.instance }}"

      - alert: HighLinkUtilization
        expr: (rate(ifHCInOctets[5m])*8 / ifHighSpeed / 1e6) > 0.85
        for: 10m
        labels: {severity: warning}
        annotations:
          summary: "Link >85% utilized on {{ $labels.instance }} {{ $labels.ifName }}"

SLIs / SLOs for networks. Borrow SRE practice:

Typical network SLIs: availability (reachability via synthetic probes/BFD), latency, jitter, loss, and throughput — measured with active probes (IP SLA, TWAMP, blackbox_exporter, ThousandEyes) rather than only device counters, so you measure the user’s path.

Capacity planning. Use long-retention trend data to forecast when links, CPU, TCAM/FIB, or NAT tables will exhaust. Track the 95th-percentile utilization (the industry billing metric for transit), model growth, and provision before you cross ~70–80% sustained. Flow data additionally shows which applications or peers drive growth, informing peering and QoS decisions (see ./13-traffic-management-and-qos.md).

Tool / technique comparison

TechniqueBest forResolutionOverheadNotes
SNMP pollingbroad device metrics, health30 s–5 minmediumuniversal support; use v3, 64-bit counters
Streaming telemetry (gNMI)high-res metrics at scalesub-second / on-changelowYANG/OpenConfig; modern OS only
NetFlow/IPFIXtraffic accounting, securityflow-timeoutmediumwho-talks-to-whom, rich fields
sFlowreal-time, many fast portsnear-instant (sampled)lowstateless, statistical
Syslogevents, config/audit, faultsevent-drivenlowneeds NTP + central store
Synthetic probes (IP SLA/TWAMP/blackbox)user-path SLOs (latency/loss)secondslowactive, measures the path not the box
Packet capture (Wireshark/tcpdump)deep root-causeper-packethighsurgical use only

Best Practices

References