Tóm tắt: MDT gồm 3 khối dưới telemetry model-driven: sensor-group (lấy path YANG nào), destination-group (gửi đi đâu, encoding, giao thức) và subscription (ghép hai khối, đặt chu kỳ sample-interval tính bằng ms). Dial-out: router chủ động đẩy tới collector. Dial-in: collector kết nối vào router qua gRPC/gNMI, subscription không cần destination.
Luồng hoạt động
flowchart LR SG["sensor-group SG-IF"] --> SUB["subscription SUB-IF"] DG["destination-group DG-COLLECTOR"] --> SUB SUB -->|"dial-out gRPC :57000"| C["Telegraf cisco_telemetry_mdt"] G["gNMI client (gnmic, Telegraf gnmi)"] -->|"dial-in :57400"| R[grpc server trên router] R --> SUB C --> DB[(InfluxDB / Prometheus)]
| Dial-out | Dial-in | |
|---|---|---|
| Ai mở kết nối | Router → collector | Collector → router |
| Cần destination-group | Có | Không |
| Firewall | Mở chiều router ra collector | Mở chiều collector vào router |
| Collector restart | Router tự kết nối lại | Collector phải subscribe lại |
| Phù hợp | Nhiều router, collector cố định | Lab, tool tương tác (gnmic) |
Cấu hình
Dial-out
telemetry model-driven
destination-group DG-COLLECTOR
address-family ipv4 198.51.100.50 port 57000
encoding self-describing-gpb
protocol grpc no-tls
!
!
sensor-group SG-IF
sensor-path Cisco-IOS-XR-infra-statsd-oper:infra-statistics/interfaces/interface/latest/generic-counters
sensor-path openconfig-interfaces:interfaces/interface/state/counters
!
sensor-group SG-SYS
sensor-path Cisco-IOS-XR-wdsysmon-fd-oper:system-monitoring/cpu-utilization
!
subscription SUB-IF
sensor-group-id SG-IF sample-interval 10000
sensor-group-id SG-SYS sample-interval 30000
destination-id DG-COLLECTOR
source-interface MgmtEth0/RP0/CPU0/0
!
!
commitsample-intervalđơn vị ms.0= event-driven (chỉ gửi khi đổi, với path hỗ trợ).encoding:self-describing-gpb(kvGPB, collector không cần file.proto),gpb(compact, cần.proto),json.protocol:grpc no-tls,grpc tls-hostname <name>, hoặctcp. Mgmt trong VRF thì thêmvrf <name>dướidestination-group.
Dial-in
Không có destination-group, chỉ cần subscription và gRPC server:
grpc
port 57400
no-tls
!
telemetry model-driven
sensor-group SG-IF
sensor-path openconfig-interfaces:interfaces/interface/state/counters
!
subscription SUB-IF
sensor-group-id SG-IF sample-interval 10000
!
!Collector có thể subscribe trực tiếp theo path bằng gNMI (xem Telegraf inputs.gnmi), không bắt buộc phải khai báo subscription trên router.
Collector Telegraf cho dial-out
[[inputs.cisco_telemetry_mdt]]
transport = "grpc"
service_address = ":57000"
[inputs.cisco_telemetry_mdt.aliases]
interfaces = "openconfig-interfaces:interfaces/interface/state/counters"
ifstats = "Cisco-IOS-XR-infra-statsd-oper:infra-statistics/interfaces/interface/latest/generic-counters"aliases đổi encoding path dài thành measurement ngắn. Path native dùng key interface-name, path OpenConfig dùng key name: muốn chung schema tag source/name thì nên ưu tiên path OpenConfig.
Lệnh kiểm tra
| Mục đích | Lệnh |
|---|---|
| Tổng quan MDT | show telemetry model-driven summary |
| Trạng thái subscription | show telemetry model-driven subscription SUB-IF |
| Chi tiết, lỗi từng path | show telemetry model-driven subscription SUB-IF internal |
| Trạng thái kết nối tới collector | show telemetry model-driven destination |
| Path có hợp lệ không | show telemetry model-driven sensor-group SG-IF |
| Cấu hình gRPC | show running-config grpc |
Lỗi thường gặp
| Triệu chứng | Nguyên nhân | Cách xử lý |
|---|---|---|
Destination không lên trạng thái Active |
Collector chưa listen, ACL/firewall, sai VRF | nc -l hoặc ss -lntp trên collector, thêm vrf ở destination-group |
Sensor path Not Resolved |
Sai tên model/path hoặc model không có trên bản XR | Kiểm tra bằng gnmic get hoặc YANG model trên router |
| Collector nhận được nhưng decode lỗi | Dùng encoding gpb (compact) trong khi collector chờ kvGPB |
Đổi sang self-describing-gpb |
| Lệch TLS | Router no-tls nhưng collector bật TLS (hoặc ngược lại) |
Đồng bộ hai phía |
| CPU router tăng | sample-interval quá nhỏ cho path lớn |
Tăng lên ≥ 10000 ms, tách sensor-group theo tần suất |
| Dữ liệu đi sai interface nguồn | Thiếu source-interface |
Đặt source-interface đúng VRF mgmt |