Sổ tay kỹ thuật

Dựng Akvorado thu thập flow

how-to#akvorado#netflow#sflow#clickhouse· cập nhật 2026-11-06

Dùng khi cần dựng collector flow Akvorado bằng Docker Compose, cấu hình router export flow và enrichment SNMP/GeoIP.

Sửa trang này
Mục lục

Tóm tắt: Akvorado nhận NetFlow v9/IPFIX/sFlow, làm giàu dữ liệu (tên interface qua SNMP, ASN/quốc gia qua GeoIP, classifier) rồi ghi vào ClickHouse; giao diện web để vẽ top talkers. Cách nhanh nhất là bản quickstart Docker Compose. Router chỉ cần export flow + mở SNMP cho collector.

Luồng hoạt động

flowchart LR R["Router (NetFlow/IPFIX :2055)"] --> IN[inlet] SW["Switch (sFlow :6343)"] --> IN IN --> K[(Kafka)] K --> OUT["outlet: decode + enrich"] OUT -->|SNMP poll| R OUT --> CH[(ClickHouse)] ORC[orchestrator] -.->|"config, schema, GeoIP"| OUT CH --> CON["console :8081"]
Thành phần Vai trò
inlet Nhận UDP flow, đẩy vào Kafka
outlet Giải mã flow, enrichment (SNMP, GeoIP, classifier), ghi ClickHouse (bản 2.x; bản 1.x việc này nằm ở inlet)
orchestrator Phân phối cấu hình, tạo bảng/dictionary trong ClickHouse
console Web UI và API
Kafka, ClickHouse Hàng đợi và kho dữ liệu

Cấu hình

Chạy quickstart

mkdir akvorado && cd akvorado
curl -sL https://github.com/akvorado/akvorado/releases/latest/download/docker-compose-quickstart.tar.gz | tar zxvf -
docker compose up -d
docker compose ps

Mở http://<host>:8081. Bản quickstart có sẵn demo exporter sinh flow giả: tắt nó trong file .env / compose override trước khi dùng thật (xem hướng dẫn trong tarball). Mẫu compose override xem Docker Compose patterns.

Router IOS XR: NetFlow v9

sampler-map SAMPLE-1K
 random 1 out-of 1024
!
flow exporter-map AKVORADO
 version v9
  options interface-table timeout 60
  options sampler-table timeout 60
  template data timeout 60
 !
 transport udp 2055
 source Loopback0
 destination 198.51.100.50
!
flow monitor-map MON-V4
 record ipv4
 exporter AKVORADO
 cache timeout active 10
 cache timeout inactive 10
!
flow monitor-map MON-V6
 record ipv6
 exporter AKVORADO
 cache timeout active 10
!
interface HundredGigE0/0/0/0
 flow ipv4 monitor MON-V4 sampler SAMPLE-1K ingress
 flow ipv6 monitor MON-V6 sampler SAMPLE-1K ingress
!
snmp-server community <community> RO

Switch Junos: sFlow

set protocols sflow collector 198.51.100.50 udp-port 6343
set protocols sflow sample-rate ingress 1024
set protocols sflow polling-interval 20
set protocols sflow agent-id 198.51.100.21
set protocols sflow interfaces et-0/0/0
set snmp community <community> authorization read-only

Enrichment

  • SNMP: Akvorado poll ifName, ifDescr, ifSpeed theo ifIndex có trong flow. Khai báo community theo dải IP exporter trong akvorado.yaml (key cụ thể khác nhau giữa 1.x và 2.x, xem file mẫu trong quickstart).
  • GeoIP: quickstart tự tải cơ sở dữ liệu ASN/country dạng MMDB. Có thể trỏ sang file MaxMind GeoLite2 nếu có license.
  • Classifier: gán Boundary/Connectivity/Provider dựa trên description interface. Nên chuẩn hoá description trên router, ví dụ Transit: example-net.
config/outlet.yaml (trích)
core:
  exporter-classifiers:
    - ClassifySiteRegex(Exporter.Name, "^([^-]+)-", "$1")
  interface-classifiers:
    - |
      Interface.Description startsWith "Transit:" &&
      ClassifyConnectivity("transit") &&
      ClassifyExternal() &&
      ClassifyProviderRegex(Interface.Description, "^Transit: ([^ ]+)", "$1")
    - ClassifyInternal()

Kiểm tra

sudo tcpdump -ni any 'udp port 2055 or udp port 6343' -c 20      # flow có tới host không
docker compose logs -f akvorado-inlet akvorado-outlet | grep -i -E 'error|template'
docker compose exec clickhouse clickhouse-client -q "SELECT ExporterName, count() FROM flows WHERE TimeReceived > now() - INTERVAL 5 MINUTE GROUP BY 1"

Query top talkers xem ClickHouse top talkers.

Lỗi thường gặp

Triệu chứng Nguyên nhân Cách xử lý
tcpdump thấy flow, UI trống Chưa nhận template (NetFlow/IPFIX) Chờ hết template data timeout, đặt timeout 60 s
Bytes nhỏ hơn thực tế hàng nghìn lần Collector không biết sampling rate Bật options sampler-table trên XR
Tên interface trống, chỉ có ifIndex SNMP bị chặn hoặc sai community snmpwalk -v2c -c <community> 198.51.100.11 ifName từ host collector
Exporter hiện IP lạ Router export từ interface khác Đặt source Loopback0, cho phép IP đó trong cấu hình SNMP
Thiếu traffic hoặc gấp đôi Bật sampling cả ingress và egress, hoặc thiếu interface Chỉ bật ingress trên mọi interface
ClickHouse đầy disk TTL dài cho bảng raw Giảm TTL, xem ClickHouse vận hành

Tham khảo