# monogon/netmeta architecture

> Architecture diagram of the GitHub repository monogon/netmeta, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/monogon/netmeta
- Repository: https://github.com/monogon/netmeta

## Overview

NetMeta is a network-flow observability toolkit. Its principal workflow collects sFlow/NetFlow/IPFIX (and mirrored packets), sends flow events through Kafka to ClickHouse, then exposes them to Grafana for analysis. The single-node deployment also includes schema reconciliation and dashboards; the port-mirror collector and RouteViews lookup service are distinct runtime components. Source excerpts show port-mirror packet processing and ClickHouse reconciliation, while several deployment components are represented from the README and tree rather than inspected source.

Main entry points: [`cmd/reconciler/main.go`](https://github.com/monogon/netmeta/blob/main/cmd/reconciler/main.go) (Reconcile runner), [`cmd/portmirror/iface.go`](https://github.com/monogon/netmeta/blob/main/cmd/portmirror/iface.go) (Interface workers), [`cmd/reconciler/reconciler.go`](https://github.com/monogon/netmeta/blob/main/cmd/reconciler/reconciler.go) (Schema reconciler), [`cmd/portmirror/portmirror.go`](https://github.com/monogon/netmeta/blob/main/cmd/portmirror/portmirror.go) (Port mirror)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Flow collection"]
  node_goflow["Flow collector"]
  node_portmirror["Port mirror<br/>[portmirror.go]"]
  node_frame_parser["Frame parser<br/>[frame.go]"]
  node_interface_workers["Interface workers<br/>[iface.go]"]
end

subgraph group_storage["Storage and schema"]
  node_kafka["Kafka broker"]
  node_clickhouse[("ClickHouse")]
  node_flow_schema["Flow schema<br/>[FlowMessage.proto]"]
  node_db_options["Column options<br/>[DBManager.proto]"]
  node_reconciler["Schema reconciler<br/>[reconciler.go]"]
  node_reconcile_entry["Reconcile runner<br/>[main.go]"]
  node_proto_visitor["Proto visitor<br/>[visitor.go]"]
  node_reconcile_config["Reconcile config<br/>[config.go]"]
  node_quote_helpers["SQL quoting<br/>[quote.go]"]
end

subgraph group_analysis["Analysis and enrichment"]
  node_grafana["Grafana"]
  node_dashboards["Dashboards"]
  node_risinfo["RIB lookup service<br/>[risinfo.go]"]
end

subgraph group_deployment["Single-node deployment"]
  node_deployment_config["Deployment config<br/>[config.cue]"]
  node_deployment_tools["Apply and diff"]
end

node_operator(("Network operator"))
node_flow_sources(("Flow sources"))
node_kubernetes["Kubernetes"]

node_flow_sources -->|"sFlow, NetFlow/IPFIX"| node_goflow
node_goflow -->|"publishes flows"| node_kafka
node_flow_sources -.->|"mirrored packets"| node_portmirror
node_portmirror -->|"starts workers"| node_interface_workers
node_interface_workers -->|"parses frames"| node_frame_parser
node_interface_workers -->|"sends flow events"| node_kafka
node_kafka -->|"streams flows"| node_clickhouse
node_clickhouse -->|"SQL queries"| node_grafana
node_operator -.->|"analyzes traffic"| node_grafana
node_dashboards -.->|"configures views"| node_grafana
node_reconcile_entry -->|"loads config"| node_reconcile_config
node_reconcile_entry -->|"runs periodically"| node_reconciler
node_reconcile_entry -->|"opens connection"| node_clickhouse
node_reconciler -->|"reads and updates schema"| node_clickhouse
node_reconcile_entry -->|"visits parsed messages"| node_proto_visitor
node_proto_visitor -.->|"maps fields"| node_flow_schema
node_flow_schema -->|"uses column annotations"| node_db_options
node_quote_helpers -.->|"quotes SQL"| node_reconciler
node_risinfo -.->|"serves RIB lookups"| node_operator
node_operator -->|"sets deployment"| node_deployment_config
node_deployment_config -.->|"drives deployment"| node_deployment_tools
node_deployment_tools -.->|"deploys services"| node_kubernetes

click node_portmirror "https://github.com/monogon/netmeta/blob/main/cmd/portmirror/portmirror.go"
click node_frame_parser "https://github.com/monogon/netmeta/blob/main/cmd/portmirror/frame.go"
click node_interface_workers "https://github.com/monogon/netmeta/blob/main/cmd/portmirror/iface.go"
click node_flow_schema "https://github.com/monogon/netmeta/blob/main/deploy/single-node/schema/FlowMessage.proto"
click node_db_options "https://github.com/monogon/netmeta/blob/main/deploy/single-node/schema/DBManager.proto"
click node_reconciler "https://github.com/monogon/netmeta/blob/main/cmd/reconciler/reconciler.go"
click node_reconcile_entry "https://github.com/monogon/netmeta/blob/main/cmd/reconciler/main.go"
click node_proto_visitor "https://github.com/monogon/netmeta/blob/main/cmd/reconciler/visitor.go"
click node_reconcile_config "https://github.com/monogon/netmeta/blob/main/cmd/reconciler/config.go"
click node_quote_helpers "https://github.com/monogon/netmeta/blob/main/cmd/reconciler/quote.go"
click node_dashboards "https://github.com/monogon/netmeta/tree/main/deploy/dashboards"
click node_risinfo "https://github.com/monogon/netmeta/blob/main/cmd/risinfo/risinfo.go"
click node_deployment_config "https://github.com/monogon/netmeta/blob/main/deploy/single-node/config.cue"
click node_deployment_tools "https://github.com/monogon/netmeta/tree/main/deploy/single-node"

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_goflow,node_portmirror,node_frame_parser,node_interface_workers toneBlue
class node_kafka,node_clickhouse,node_flow_schema,node_db_options,node_reconciler,node_reconcile_entry,node_proto_visitor,node_reconcile_config,node_quote_helpers toneAmber
class node_grafana,node_dashboards,node_risinfo toneMint
class node_deployment_config,node_deployment_tools toneRose
class node_operator,node_flow_sources,node_kubernetes toneIndigo
```

## Components

### Flow collection

- **Flow collector**
- [Port mirror](https://github.com/monogon/netmeta/blob/main/cmd/portmirror/portmirror.go): `cmd/portmirror/portmirror.go`
- [Frame parser](https://github.com/monogon/netmeta/blob/main/cmd/portmirror/frame.go): `cmd/portmirror/frame.go`
- [Interface workers](https://github.com/monogon/netmeta/blob/main/cmd/portmirror/iface.go): `cmd/portmirror/iface.go`

### Storage and schema

- **Kafka broker**
- **ClickHouse**
- [Flow schema](https://github.com/monogon/netmeta/blob/main/deploy/single-node/schema/FlowMessage.proto): `deploy/single-node/schema/FlowMessage.proto`
- [Column options](https://github.com/monogon/netmeta/blob/main/deploy/single-node/schema/DBManager.proto): `deploy/single-node/schema/DBManager.proto`
- [Schema reconciler](https://github.com/monogon/netmeta/blob/main/cmd/reconciler/reconciler.go): `cmd/reconciler/reconciler.go`
- [Reconcile runner](https://github.com/monogon/netmeta/blob/main/cmd/reconciler/main.go): `cmd/reconciler/main.go`
- [Proto visitor](https://github.com/monogon/netmeta/blob/main/cmd/reconciler/visitor.go): `cmd/reconciler/visitor.go`
- [Reconcile config](https://github.com/monogon/netmeta/blob/main/cmd/reconciler/config.go): `cmd/reconciler/config.go`
- [SQL quoting](https://github.com/monogon/netmeta/blob/main/cmd/reconciler/quote.go): `cmd/reconciler/quote.go`

### Analysis and enrichment

- **Grafana**
- [Dashboards](https://github.com/monogon/netmeta/tree/main/deploy/dashboards): `deploy/dashboards`
- [RIB lookup service](https://github.com/monogon/netmeta/blob/main/cmd/risinfo/risinfo.go): `cmd/risinfo/risinfo.go`

### Single-node deployment

- [Deployment config](https://github.com/monogon/netmeta/blob/main/deploy/single-node/config.cue): `deploy/single-node/config.cue`
- [Apply and diff](https://github.com/monogon/netmeta/tree/main/deploy/single-node): `deploy/single-node`

### Other components

- **Network operator**
- **Flow sources**
- **Kubernetes**

## Connections

- Flow sources → Flow collector: sFlow, NetFlow/IPFIX (evidence: `README.md`)
- Flow collector → Kafka broker: publishes flows (evidence: `README.md`)
- Flow sources → Port mirror: mirrored packets (evidence: `README.md`)
- Port mirror → Interface workers: starts workers (evidence: `cmd/portmirror/portmirror.go`)
- Interface workers → Frame parser: parses frames (evidence: `cmd/portmirror/iface.go`)
- Interface workers → Kafka broker: sends flow events (evidence: `cmd/portmirror/iface.go`)
- Kafka broker → ClickHouse: streams flows (evidence: `README.md`)
- ClickHouse → Grafana: SQL queries (evidence: `README.md`)
- Network operator → Grafana: analyzes traffic (evidence: `README.md`)
- Dashboards → Grafana: configures views (evidence: `README.md`)
- Reconcile runner → Reconcile config: loads config (evidence: `cmd/reconciler/main.go`)
- Reconcile runner → Schema reconciler: runs periodically (evidence: `cmd/reconciler/main.go`)
- Reconcile runner → ClickHouse: opens connection (evidence: `cmd/reconciler/main.go`)
- Schema reconciler → ClickHouse: reads and updates schema (evidence: `cmd/reconciler/reconciler.go`)
- Reconcile runner → Proto visitor: visits parsed messages (evidence: `cmd/reconciler/main.go`)
- Proto visitor → Flow schema: maps fields
- Flow schema → Column options: uses column annotations (evidence: `deploy/single-node/schema/FlowMessage.proto`)
- SQL quoting → Schema reconciler: quotes SQL
- RIB lookup service → Network operator: serves RIB lookups (evidence: `cmd/risinfo/risinfo.go`)
- Network operator → Deployment config: sets deployment (evidence: `README.md`)
- Deployment config → Apply and diff: drives deployment
- Apply and diff → Kubernetes: deploys services (evidence: `README.md`)
