Network management as a Neo4j graph model

Neo4j's network management example, drawn as a graph data model: a data center with its hardware, its network, and the software that runs on it. One node per label combination, every property with its Neo4j type, and the complete Cypher to create it.

Open this model in toro4n Network management as a Neo4j graph model drawn in toro4n, with the layers panel on the right

What the model shows

The model describes a data center from the racks down to the processes. Hardware is a chain of containment: a data center has zones, a zone has racks, a rack holds machines, and a machine has interfaces and ports. The network connects interfaces to networks and routers, and an egress router carries two labels, Router and Egress. Software is modeled as software with versions that form a chain, and a process is one running instance of a version on a machine. The monitoring part of Neo4j's guide adds connections between ports, each opened from one port to another.

It is the most complex of Neo4j's official examples, which makes it a good model to learn from: several nodes carry two labels, there are relationships from a node to itself, and some pairs of nodes are connected by more than one relationship. It is also a realistic test case for a graph modeling tool, with three layers (Software, Network, Hardware) and notes attached to the parts they explain.

In numbers: 19 nodes with 18 labels, 38 relationships of 17 types, 3 layers, and 6 notes. The model is a schema: each node stands for a label or a label combination, and each property shows its Neo4j type and, where one helps, an example. The Cypher below creates one node per label combination and one relationship per connection, with the example or the type name as the value, so it runs as it is.

Nodes and properties

Each property is written as the app draws it under the node: key, type, and example, with the Neo4j constraints that apply to it.

Application:Process

Connection

DataCenter

Interface

Machine

Network:Zone

Os:Process

Port

Rack

Router

Router:Egress

Service:Process

Software

Software:Application

Software:Os

Software:Service

Switch

Type

Version

Relationships

Layers and notes

The notes in the model:

Cypher

Exactly what toro4n exports for this model: a constraint for every unique or required property, then one CREATE statement per node and per relationship, ready to run in Neo4j.

CREATE (DataCenter:DataCenter {name: "STRING", location: "STRING"})
CREATE (Type:Type {id: "INTEGER", name: "STRING", type: "STRING", cpu: "INTEGER", ram: "INTEGER", disk: "INTEGER"})
CREATE (Machine:Machine {id: "INTEGER", name: "STRING"})
CREATE (Rack:Rack {name: "STRING", rack: "INTEGER", zone: "INTEGER"})
CREATE (Switch:Switch {ip: "STRING", rack: "INTEGER"})
CREATE (Router:Router {name: "STRING", zone: "INTEGER"})
CREATE (RouterEgress:Router:Egress {name: "STRING"})
CREATE (Interface:Interface {ip: "STRING"})
CREATE (NetworkZone:Network:Zone {ip: "STRING", size: "INTEGER", zone: "INTEGER"})
CREATE (Port:Port {port: "INTEGER"})
CREATE (Connection:Connection {id: "STRING", source: "STRING", target: "STRING", user: "STRING", time: "INTEGER"})
CREATE (OsProcess:Os:Process {name: "STRING", startTime: "INTEGER"})
CREATE (ApplicationProcess:Application:Process {name: "STRING", pid: "INTEGER", startTime: "INTEGER"})
CREATE (ServiceProcess:Service:Process {name: "STRING", pid: "INTEGER", startTime: "INTEGER"})
CREATE (Version:Version {name: "STRING"})
CREATE (SoftwareOs:Software:Os {name: "STRING", versions: "LIST<STRING>"})
CREATE (SoftwareApplication:Software:Application {name: "STRING", ports: "LIST<INTEGER>", dependencies: "LIST<STRING>"})
CREATE (SoftwareService:Software:Service {name: "STRING", versions: "LIST<STRING>", ports: "LIST<INTEGER>", dependencies: "LIST<STRING>"})
CREATE (Software:Software {name: "STRING"})
CREATE (DataCenter)-[:CONTAINS]->(Router)
CREATE (DataCenter)-[:CONTAINS]->(RouterEgress)
CREATE (DataCenter)-[:CONTAINS]->(Rack)
CREATE (Rack)-[:HOLDS]->(Switch)
CREATE (Rack)-[:HOLDS]->(Machine)
CREATE (Machine)-[:TYPE]->(Type)
CREATE (Router)-[:ROUTES]->(Interface)
CREATE (RouterEgress)-[:ROUTES]->(Interface)
CREATE (Switch)-[:ROUTES]->(Interface)
CREATE (Machine)-[:ROUTES]->(Interface)
CREATE (NetworkZone)-[:ROUTES]->(Interface)
CREATE (Interface)-[:CONNECTS]->(NetworkZone)
CREATE (Interface)-[:CONNECTS]->(Interface)
CREATE (Interface)-[:CONNECTIONS]->(Interface)
CREATE (Interface)-[:EXPOSES]->(Port)
CREATE (Interface)-[:OPENS]->(Port)
CREATE (Interface)-[:LISTENS]->(Port)
CREATE (Connection)-[:FROM]->(Port)
CREATE (Connection)-[:TO]->(Port)
CREATE (Machine)-[:RUNS]->(OsProcess)
CREATE (Machine)-[:RUNS]->(ApplicationProcess)
CREATE (Machine)-[:RUNS]->(ServiceProcess)
CREATE (Machine)-[:UPDATE_TO {ts: "INTEGER"}]->(Version)
CREATE (ApplicationProcess)-[:LISTENS]->(Port)
CREATE (ServiceProcess)-[:LISTENS]->(Port)
CREATE (ApplicationProcess)-[:DEPENDS_ON]->(ServiceProcess)
CREATE (OsProcess)-[:INSTANCE]->(Version)
CREATE (ApplicationProcess)-[:INSTANCE]->(SoftwareApplication)
CREATE (ServiceProcess)-[:INSTANCE]->(SoftwareService)
CREATE (ServiceProcess)-[:INSTANCE]->(Version)
CREATE (SoftwareOs)-[:VERSION]->(Version)
CREATE (SoftwareService)-[:VERSION]->(Version)
CREATE (Software)-[:VERSION]->(Version)
CREATE (Version)-[:PREVIOUS]->(Version)
CREATE (SoftwareService)-[:DEPENDS_ON]->(Version)
CREATE (SoftwareApplication)-[:DEPENDS_ON]->(Version)
CREATE (SoftwareApplication)-[:DEPENDS_ON]->(SoftwareService)
CREATE (SoftwareApplication)-[:DEPENDS_ON]->(Software)

Source

The data comes from neo4j-graph-examples/network-management on GitHub. The model file is network-management.json, and the app's own copy opens with this link.