# ivanbutram/zeek-anomaly-detector architecture

> Architecture diagram of the GitHub repository ivanbutram/zeek-anomaly-detector, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ivanbutram/zeek-anomaly-detector
- Repository: https://github.com/ivanbutram/zeek-anomaly-detector

## Overview

This repository contains two command-line tools for Zeek connection logs: a connection filter and an anomaly detector. The detector validates and parses JSON records, evaluates volume, connection-rate, and distinct-port thresholds, then writes JSON or Russian human-readable warnings. The filter parses records and emits those involving an optional server IP. The README gives only the project name; these workflows are supported by the sampled source. Documentation-listed capabilities are not detailed because their contents were not provided.

Main entry points: [`cmd/detect/main.go`](https://github.com/ivanbutram/zeek-anomaly-detector/blob/main/cmd/detect/main.go) (Detector command), [`main.go`](https://github.com/ivanbutram/zeek-anomaly-detector/blob/main/main.go) (Filter command), [`cmd/detect/output.go`](https://github.com/ivanbutram/zeek-anomaly-detector/blob/main/cmd/detect/output.go) (Report formatting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_filter["Connection filter"]
  node_filter_cli["Filter command<br/>[main.go]"]
  node_filter_parse["Parse and filter<br/>[main.go]"]
end

subgraph group_detector["Anomaly detection"]
  node_detect_cli["Detector command<br/>[main.go]"]
  node_record_validation["Validate and parse<br/>[main.go]"]
  node_threshold_detection["Threshold detection<br/>[main.go]"]
end

subgraph group_reporting["Alert reporting"]
  node_alerts["Alert records<br/>[main.go]"]
  node_report_writer["Report formatting<br/>[output.go]"]
end

node_operator(("CLI operator"))
node_zeek_log["Zeek conn.log"]
node_filtered_records["Filtered JSON records"]
node_report_output["Report output"]

node_operator -->|"runs"| node_filter_cli
node_zeek_log -->|"provides log"| node_filter_cli
node_filter_cli -->|"parses and filters"| node_filter_parse
node_filter_parse -->|"encodes records"| node_filtered_records
node_operator -->|"runs"| node_detect_cli
node_zeek_log -->|"provides log"| node_detect_cli
node_detect_cli -->|"validates records"| node_record_validation
node_detect_cli -->|"calls detect"| node_threshold_detection
node_threshold_detection -->|"produces alerts"| node_alerts
node_detect_cli -->|"writes report"| node_report_writer
node_alerts -->|"formats alerts"| node_report_writer
node_report_writer -->|"writes output"| node_report_output

click node_filter_cli "https://github.com/ivanbutram/zeek-anomaly-detector/blob/main/main.go"
click node_filter_parse "https://github.com/ivanbutram/zeek-anomaly-detector/blob/main/main.go"
click node_detect_cli "https://github.com/ivanbutram/zeek-anomaly-detector/blob/main/cmd/detect/main.go"
click node_record_validation "https://github.com/ivanbutram/zeek-anomaly-detector/blob/main/cmd/detect/main.go"
click node_threshold_detection "https://github.com/ivanbutram/zeek-anomaly-detector/blob/main/cmd/detect/main.go"
click node_alerts "https://github.com/ivanbutram/zeek-anomaly-detector/blob/main/cmd/detect/main.go"
click node_report_writer "https://github.com/ivanbutram/zeek-anomaly-detector/blob/main/cmd/detect/output.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_filter_cli,node_filter_parse toneBlue
class node_detect_cli,node_record_validation,node_threshold_detection toneAmber
class node_alerts,node_report_writer toneMint
class node_operator,node_zeek_log,node_filtered_records,node_report_output toneIndigo
```

## Components

### Connection filter

- [Filter command](https://github.com/ivanbutram/zeek-anomaly-detector/blob/main/main.go): `main.go`
- [Parse and filter](https://github.com/ivanbutram/zeek-anomaly-detector/blob/main/main.go): `main.go`

### Anomaly detection

- [Detector command](https://github.com/ivanbutram/zeek-anomaly-detector/blob/main/cmd/detect/main.go): `cmd/detect/main.go`
- [Validate and parse](https://github.com/ivanbutram/zeek-anomaly-detector/blob/main/cmd/detect/main.go): `cmd/detect/main.go`
- [Threshold detection](https://github.com/ivanbutram/zeek-anomaly-detector/blob/main/cmd/detect/main.go): `cmd/detect/main.go`

### Alert reporting

- [Alert records](https://github.com/ivanbutram/zeek-anomaly-detector/blob/main/cmd/detect/main.go): `cmd/detect/main.go`
- [Report formatting](https://github.com/ivanbutram/zeek-anomaly-detector/blob/main/cmd/detect/output.go): `cmd/detect/output.go`

### Other components

- **CLI operator**
- **Zeek conn.log**
- **Filtered JSON records**
- **Report output**

## Connections

- CLI operator → Filter command: runs (evidence: `main.go`)
- Zeek conn.log → Filter command: provides log (evidence: `main.go`)
- Filter command → Parse and filter: parses and filters (evidence: `main.go`)
- Parse and filter → Filtered JSON records: encodes records (evidence: `main.go`)
- CLI operator → Detector command: runs (evidence: `cmd/detect/main.go`)
- Zeek conn.log → Detector command: provides log (evidence: `cmd/detect/main.go`)
- Detector command → Validate and parse: validates records (evidence: `cmd/detect/main.go`)
- Detector command → Threshold detection: calls detect (evidence: `cmd/detect/main.go`)
- Threshold detection → Alert records: produces alerts (evidence: `cmd/detect/main.go`)
- Detector command → Report formatting: writes report (evidence: `cmd/detect/main.go`)
- Alert records → Report formatting: formats alerts (evidence: `cmd/detect/main.go`)
- Report formatting → Report output: writes output (evidence: `cmd/detect/output.go`)
