# robotneo/networkdevice-monitor architecture

> Architecture diagram of the GitHub repository robotneo/networkdevice-monitor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/robotneo/networkdevice-monitor
- Repository: https://github.com/robotneo/networkdevice-monitor

## Overview

##### Project type and purpose
- This is a specialized monitoring/alerting stack for network devices (switches, wireless LAN controllers, firewalls, etc.) using Prometheus, SNMP Exporter, Grafana, and VictoriaMetrics.
- It includes a “generator” CLI tool that consumes MIB files and vendor templates to produce SNMP‐Exporter scrape configs (snmp.yml), plus ready‐made Prometheus alerting rules and full deployment manifests for VictoriaMetrics clusters, Prometheus, Grafana dashboards, Alertmanager, vmalert/vmagent/vmauth, and promxy.

##### File structure
- Top level:
- generator/ – MIBs, per-vendor generator.yml files, and the Go‐based generator utility
- prometheus/ – alerting rules broken out by environment (prod, vm)
- victoriametrics/ – binaries, cluster/docker-compose and provisioning for VM services (vminsert, vmselect, vmstorage, vmalert, vmagent, vmauth, Alertmanager, Grafana dashboards)
- promxy/ – a Prometheus proxy with its own alert rules, dashboards, and compose setup

##### Extract architecture insights from README
- The generator produces SNMP Exporter configs from MIBs.
- SNMP Exporter runs as a long-running service on a Linux host, exposing device metrics.
- Prometheus scrapes SNMP Exporter; uses supplied rules to fire alerts.
- VictoriaMetrics (single or clustered) is the long-term store.
- Grafana presents dashboards; vmalert sends PromQL-driven alerts to Alertmanager; Alertmanager delivers notifications.
- promxy can sit between Prometheus and VictoriaMetrics as a caching proxy.

##### Main components & their interactions
a. Network devices (SNMP agents)
b. generator CLI + MIB/templates → outputs snmp.yml
c. SNMP Exporter service (reads snmp.yml, serves metrics)
d. Prometheus server (scrapes SNMP Exporter + other exporters, applies rules)
e. VictoriaMetrics storage cluster (vminsert, vmselect, vmstorage) or single node
f. promxy (optional Prometheus/VictoriaMetrics proxy)
g. vmagent (optional remote write agent)
h. vmalert (PromQL alert runner) → Alertmanager
i. Grafana (dashboards + provisioning)

Data flows:
- Generator → SNMP Exporter config
- Devices →|SNMP|→ SNMP Exporter →|HTTP scrape|→ Prometheus →|remote_write / local|→ VictoriaMetrics
- Prometheus →|alerts|→ vmalert → Alertmanager →|notifications|→ external channels
- Grafana ←|queries|→ VictoriaMetrics / promxy

##### Architectural patterns & design principles
- Microservices via containerized components (each VM service, promxy, Grafana, Alertmanager runs in its own container or binary).
- Separation of concerns:
- Configuration generation (offline CLI)
- Metrics collection (SNMP Exporter)
- Scraping & rule evaluation (Prometheus, vmalert)
- Storage (VictoriaMetrics)
- Visualization & alert dispatching (Grafana, Alertmanager)
- Infrastructure as code: Docker Compose + provisioning YAMLs for dashboards & datasources.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Offline Tools"
        direction TB
        GCL["Generator CLI Tool"]:::offline
        MIBs["Vendor MIBs & Templates"]:::offline
        SNMPCFG["snmp.yml"]:::artifact
        GCL -->|"reads templates"| MIBs
        GCL -->|"outputs snmp.yml"| SNMPCFG
    end

    subgraph "Ingestion Layer"
        direction TB
        Devices["Network Devices (SNMP Agents)"]:::external
        SNMPExp["SNMP Exporter"]:::service
        Devices -->|"SNMP"| SNMPExp
        SNMPCFG --> SNMPExp
    end

    subgraph "Scraping & Evaluation"
        direction TB
        Prom["Prometheus"]:::service
        ProdRules["prod alerts"]:::artifact
        VMRules["vm alerts"]:::artifact
        SNMPExp -->|"HTTP scrape"| Prom
        Prom -->|"uses"| ProdRules
        Prom -->|"uses"| VMRules
    end

    subgraph "Storage Layer"
        direction TB
        subgraph "VictoriaMetrics Cluster"
            direction TB
            VInsert["vminsert"]:::service
            VSelect["vmselect"]:::service
            VStorage["vmstorage"]:::service
            Prom -->|"remote_write"| VInsert
            VInsert --> VSelect
            VSelect --> VStorage
        end
        subgraph "Single-Node VM"
            direction TB
            VMSingle["VM Single Node"]:::service
            Prom -->|"local storage"| VMSingle
        end
    end

    subgraph "Optional Proxy Layer"
        direction TB
        Proxy["promxy"]:::service
        Prom -->|"read proxy"| Proxy
        Proxy --> VSelect
    end

    subgraph "Alerting & Visualization"
        direction TB
        Vmalert["vmalert"]:::service
        AlertMgr["Alertmanager"]:::alert
        Graf["Grafana"]:::viz
        Ext["Notification Channels"]:::external
        Prom -->|"alerts"| Vmalert
        Vmalert -->|"PromQL alerts"| AlertMgr
        AlertMgr -->|"notifications"| Ext
        Graf -->|"queries"| VSelect
        Graf -->|"queries"| Proxy
    end

    %% Click Events
    click GCL "https://github.com/robotneo/networkdevice-monitor/blob/main/generator/README.md"
    click MIBs "https://github.com/robotneo/networkdevice-monitor/tree/main/generator/"
    click SNMPCFG "https://github.com/robotneo/networkdevice-monitor/blob/main/generator/test/snmp.yml"
    click ProdRules "https://github.com/robotneo/networkdevice-monitor/tree/main/prometheus/rules/prod/"
    click VMRules "https://github.com/robotneo/networkdevice-monitor/tree/main/prometheus/rules/vm/"
    click VInsert "https://github.com/robotneo/networkdevice-monitor/tree/main/victoriametrics/binary/vminsert/"
    click VSelect "https://github.com/robotneo/networkdevice-monitor/tree/main/victoriametrics/binary/vmselect/"
    click VStorage "https://github.com/robotneo/networkdevice-monitor/tree/main/victoriametrics/binary/vmstorage/"
    click VMSingle "https://github.com/robotneo/networkdevice-monitor/blob/main/victoriametrics/deploy/victoriametrics/docker-compose.yml"
    click Proxy "https://github.com/robotneo/networkdevice-monitor/tree/main/victoriametrics/promxy/cmd/promxy"
    click Graf "https://github.com/robotneo/networkdevice-monitor/blob/main/victoriametrics/deploy-cluster/dashboards/victoriametrics-cluster.json"

    %% Styles
    classDef offline fill:#dddddd,stroke:#888888;
    classDef service fill:#bbdefb,stroke:#1e88e5;
    classDef artifact fill:#fff3e0,stroke:#fb8c00;
    classDef external fill:#eeeeee,stroke:#888888,stroke-dasharray:5 5;
    classDef viz fill:#c8e6c9,stroke:#388e3c;
    classDef alert fill:#ffcdd2,stroke:#e53935;
    classDef optional stroke-dasharray:5 5;
```
