Available on crate feature
emit only.Expand description
flowscope::emit — structured event sinks.
Built-in writers for the three log formats every flow-analysis pipeline ends up emitting:
FlowEventCsvWriter—flows.csvfor spreadsheets, DuckDB, pandas. RFC-4180 quoting. No extra deps.FlowEventNdjsonWriter— newline-delimited JSON for Elasticsearch / Loki / ClickHouse. Gated on theemit-ndjsonfeature (pulls inserde_jsonand requiresserde).ZeekConnLogWriter— Zeek-styleconn.logrows (tab-separated). Drop-in for existing Zeek pipelines viazeek-cut.
Each writer takes a std::io::Write sink and a single
FlowEvent<FiveTupleKey> per call. By default they emit only
FlowEvent::Ended; use the per-
writer options struct to opt into Started / Packet /
anomaly rows.
use std::fs::File;
use std::io::BufWriter;
use flowscope::emit::FlowEventCsvWriter;
use flowscope::extract::FiveTuple;
use flowscope::pcap::PcapFlowSource;
use flowscope::FlowTracker;
let f = File::create("flows.csv")?;
let mut csv = FlowEventCsvWriter::new(BufWriter::new(f))?;
let mut tracker = FlowTracker::<FiveTuple>::new(FiveTuple::bidirectional());
for owned in PcapFlowSource::open("trace.pcap")?.views() {
for ev in tracker.track(&owned?) {
csv.write_event(&ev)?;
}
}
for ev in tracker.finish() {
csv.write_event(&ev)?;
}
csv.finish()?;New in 0.10.0 (plan 101).
Structs§
- CsvOptions
- Options for
FlowEventCsvWriter. - EveJson
Writer emit-eve - Suricata EVE JSON writer. One JSON object per line.
- EveOptions
emit-eve - Options for
EveJsonWriter. - Flow
Event CsvWriter - CSV writer for
FlowEventstreams. - Flow
Event Ndjson Writer emit-ndjson - Newline-delimited JSON writer for
FlowEventstreams. - Ndjson
Options emit-ndjson - Options for
FlowEventNdjsonWriter. - Zeek
Conn LogWriter - Tab-separated Zeek
conn.logwriter forFlowEventstreams. - Zeek
Options - Options for
ZeekConnLogWriter.
Traits§
- Lifecycle
Event - A lifecycle event the
emitwriters can consume — implemented by bothFlowEvent(the tracker primitive) and the typed driver’sEvent(issue #97).