How cloudflare/goflow works
GoFlow is a UDP collector for NetFlow v5, NetFlow v9/IPFIX, and sFlow v5. Its principal workflow receives packets, decodes protocol-specific records (including NetFlow templates and options), converts samples into a shared protobuf flow message, then publishes through Kafka or console transports. The multi-protocol CLI starts collector states and exposes metrics and NetFlow template information. README capabilities are represented where source details were not sampled; links without direct evidence are omitted.
Main entry points: netflow.go NetFlow state · sflow.go sFlow state · nflegacy.go v5 state · utils.go Transport selection
Components 23
Collector entrypoints
- Multi-protocol CLI
cmd/goflow/goflow.go - NetFlow CLI
cmd/cnetflow/cnetflow.go - NetFlow v5 CLI
cmd/cnflegacy/cnflegacy.go - sFlow CLI
cmd/csflow/csflow.go - NetFlow state
utils/netflow.go - v5 state
utils/nflegacy.go - sFlow state
utils/sflow.go
Protocol decoding
- NetFlow v9/IPFIX decoder
decoders/netflow/netflow.go - NetFlow v5 decoder
decoders/netflowlegacy/netflow.go - sFlow v5 decoder
decoders/sflow/sflow.go - Template handling
decoders/netflow/netflow.go
Flow production
- NetFlow producer
producer/producer_nf.go - v5 producer
producer/producer_nflegacy.go - sFlow producer
producer/producer_sf.go - Flow protobuf
pb/flow.proto
Output and monitoring
- Transport selection
utils/utils.go - Kafka publisher
transport/kafka.go - Console output
utils/utils.go - Prometheus metrics
utils/metrics.go - Metrics and templates HTTP
cmd/goflow/goflow.go
Other components
- Flow exporters
- Kafka brokers
- Prometheus scraper
Connections 29
- Flow exporters → Multi-protocol CLI: send UDP
README.md - Multi-protocol CLI → NetFlow state: starts collectors
cmd/goflow/goflow.go - Multi-protocol CLI → sFlow state: starts collectors
cmd/goflow/goflow.go - Multi-protocol CLI → v5 state: starts collectors
cmd/goflow/goflow.go - NetFlow CLI → NetFlow state: starts collector
cmd/cnetflow/cnetflow.go - NetFlow v5 CLI → v5 state: starts collector
cmd/cnflegacy/cnflegacy.go - sFlow CLI → sFlow state: starts collector
cmd/csflow/csflow.go - NetFlow state → NetFlow v9/IPFIX decoder: decodes packet
utils/netflow.go - NetFlow state → Template handling: maintains templates
utils/netflow.go - NetFlow state → NetFlow producer: converts records
producer/producer_nf.go - v5 state → NetFlow v5 decoder: decodes packet
utils/nflegacy.go - v5 state → v5 producer: converts records
utils/nflegacy.go - sFlow state → sFlow v5 decoder: decodes packet
utils/sflow.go - sFlow state → sFlow producer: processes samples
utils/sflow.go - NetFlow producer → Flow protobuf: builds messages
producer/producer_nf.go - v5 producer → Flow protobuf: builds messages
producer/producer_nflegacy.go - sFlow producer → Flow protobuf: builds messages
producer/producer_sf.go - NetFlow state → Transport selection: publishes flows
utils/netflow.go - v5 state → Transport selection: publishes flows
utils/nflegacy.go - sFlow state → Transport selection: publishes flows
utils/sflow.go - Transport selection → Kafka publisher: selects publisher
- Transport selection → Console output: selects fallback
utils/utils.go - Kafka publisher → Flow protobuf: serializes messages
transport/kafka.go - Kafka publisher → Kafka brokers: sends records
transport/kafka.go - Metrics and templates HTTP → Prometheus metrics: serves metrics
cmd/goflow/goflow.go - Metrics and templates HTTP → Template handling: serves template view
cmd/goflow/goflow.go - Prometheus scraper → Metrics and templates HTTP: scrapes metrics
README.md - NetFlow state → Prometheus metrics: records decode stats
utils/netflow.go - sFlow state → Prometheus metrics: records decode stats
utils/sflow.go