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
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
name: STRINGpid: INTEGERstartTime: INTEGER
Connection
id: STRINGsource: STRINGtarget: STRINGuser: STRINGtime: INTEGER
DataCenter
name: STRINGlocation: STRING
Interface
ip: STRING
Machine
id: INTEGERname: STRING
Network:Zone
ip: STRINGsize: INTEGERzone: INTEGER
Os:Process
name: STRINGstartTime: INTEGER
Port
port: INTEGER
Rack
name: STRINGrack: INTEGERzone: INTEGER
Router
name: STRINGzone: INTEGER
Router:Egress
name: STRING
Service:Process
name: STRINGpid: INTEGERstartTime: INTEGER
Software
name: STRING
Software:Application
name: STRINGports: LIST<INTEGER>dependencies: LIST<STRING>
Software:Os
name: STRINGversions: LIST<STRING>
Software:Service
name: STRINGversions: LIST<STRING>ports: LIST<INTEGER>dependencies: LIST<STRING>
Switch
ip: STRINGrack: INTEGER
Type
id: INTEGERname: STRINGtype: STRINGcpu: INTEGERram: INTEGERdisk: INTEGER
Version
name: STRING
Relationships
(DataCenter)-[:CONTAINS]->(Router)(DataCenter)-[:CONTAINS]->(Router, Egress)(DataCenter)-[:CONTAINS]->(Rack)(Rack)-[:HOLDS]->(Switch)(Rack)-[:HOLDS]->(Machine)(Machine)-[:TYPE]->(Type)(Router)-[:ROUTES]->(Interface)(Router, Egress)-[:ROUTES]->(Interface)(Switch)-[:ROUTES]->(Interface)(Machine)-[:ROUTES]->(Interface)(Network, Zone)-[:ROUTES]->(Interface)(Interface)-[:CONNECTS]->(Network, Zone)(Interface)-[:CONNECTS]->(Interface)(Interface)-[:CONNECTIONS]->(Interface)(Interface)-[:EXPOSES]->(Port)(Interface)-[:OPENS]->(Port)(Interface)-[:LISTENS]->(Port)(Connection)-[:FROM]->(Port)(Connection)-[:TO]->(Port)(Machine)-[:RUNS]->(Os, Process)(Machine)-[:RUNS]->(Application, Process)(Machine)-[:RUNS]->(Service, Process)(Machine)-[:UPDATE_TO]->(Version)withts: INTEGER(Application, Process)-[:LISTENS]->(Port)(Service, Process)-[:LISTENS]->(Port)(Application, Process)-[:DEPENDS_ON]->(Service, Process)(Os, Process)-[:INSTANCE]->(Version)(Application, Process)-[:INSTANCE]->(Software, Application)(Service, Process)-[:INSTANCE]->(Software, Service)(Service, Process)-[:INSTANCE]->(Version)(Software, Os)-[:VERSION]->(Version)(Software, Service)-[:VERSION]->(Version)(Software)-[:VERSION]->(Version)(Version)-[:PREVIOUS]->(Version)(Software, Service)-[:DEPENDS_ON]->(Version)(Software, Application)-[:DEPENDS_ON]->(Version)(Software, Application)-[:DEPENDS_ON]->(Software, Service)(Software, Application)-[:DEPENDS_ON]->(Software)
Layers and notes
- Software: 8 nodes
- Network: 4 nodes
- Hardware: 7 nodes
The notes in the model:
- Network management – Neo4j's example of a data center as a graph: the hardware, the network and the software that runs on it.
Each node stands for a label or a combination of labels; the properties show the Cypher type.
Source: github.com/neo4j-graph-examples/network-management - Two labels: the egress router is a Router that also carries the label Egress.
- Versions form a chain: each version points to the one before it.
- A planned upgrade is a relationship with a timestamp.
- From the monitoring part of Neo4j's guide: every opened connection becomes a node between two ports.
- A process is one running instance of a piece of software, or of one version of it.
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.