Skip to main content

Graph

Declare one GraphML topology per document. A topology is a container of ordered layers. Each layer holds vertices and edges, and a vertex can show the alarm status of an OpenNMS node. Apply writes /rest/graphml/{name}. Reads go through the v2 Graph API, /api/v2/graphs, which is read-only. See the compatibility table for supported servers.

YAML​

Graph is named and multi-instance. metadata.name is the upload name and the container id the topology UI and /api/v2/graphs show. Unknown fields are rejected.

FieldTypeDefaultDescription
apiVersionstringrequiredgraphml.opennms.org/v1
kindstringrequiredGraph
metadata.namestringrequiredUpload name and container id. Must match [A-Za-z0-9._-]+. Must be unique within an apply.
spec.labelstringnoneContainer label in the topology menu.
spec.descriptionstringnoneContainer description.
spec.breadcrumbStrategyNONE or SHORTEST_PATH_TO_ROOTnoneBreadcrumb navigation between layers.
spec.layerslist of layersrequiredThe graphs of the container, in order. Must not be empty.

Layers​

FieldTypeDefaultDescription
namespacestringrequiredUnique across the server.
labelstringnoneLayer name in the topology UI.
descriptionstringnoneShown in the info panel.
preferredLayoutstringserver: D3Layout the topology UI starts with, such as Circle Layout.
semanticZoomLevelinteger, 0 or moreserver: 1Default semantic zoom level.
focus.strategyEMPTY, ALL, FIRST or SPECIFICnoneDefault focus. Without it the layer's default view shows no vertices.
focus.verticeslist of vertex ids[]Required with SPECIFIC, rejected otherwise. Ids of this layer, without commas.
vertexStatusProviderdefault, script or propagatenonedefault: worst alarm of the vertex's node. script: Groovy scripts in etc/graphml-vertex-status. propagate: worst status of connected vertices.
edgePathOffsetinteger, 0 or moreserver: 20Spacing between parallel edges.
verticeslist of vertices[]
edgeslist of edges[]Edges whose source is a vertex of this layer.

Vertices​

FieldTypeDefaultDescription
idstringrequiredUnique across all layers of the document.
labelstringnoneDisplay name.
iconKeystringserver: genericTopology icon, such as router, switch, server or cloud.
tooltipstringnoneHover text.
levelintegerserver: 0Layout level.
node{foreignSource, foreignId}noneThe OpenNMS node whose status the vertex shows. Both fields must be non-empty.

Node references pass through to the server unchanged. A node that does not exist yet only prints a warning, so a graph can apply in the same run as the requisition that creates its nodes. The check runs only for graphs that will be written, and a failed lookup is also just a warning.

Edges​

FieldTypeDefaultDescription
idstring<source>-<target>Set it when two edges join the same pair.
sourcevertex idrequiredA vertex of the layer that declares the edge.
targetvertex idrequiredA vertex of any layer. A target in another layer makes a cross-layer edge.
tooltipstringnoneHover text.

GraphML mapping​

Apply renders the document as GraphML. graph convert and graph export read GraphML back with the same mapping.

YAMLGraphML keyOn
metadata.namecontainerIddocument
spec.label, spec.descriptionlabel, descriptiondocument
spec.breadcrumbStrategybreadcrumb-strategydocument
namespace, label, descriptionnamespace, label, descriptiongraph
preferredLayoutpreferred-layoutgraph
semanticZoomLevelsemantic-zoom-levelgraph
focus.strategy, focus.verticesfocus-strategy, focus-ids (comma-joined)graph
vertexStatusProvidervertex-status-providergraph
edgePathOffsetedge-path-offsetgraph
label, iconKey, levellabel, iconKey, levelnode
tooltiptooltipTextnode, edge
node.foreignSource, node.foreignIdforeignSource, foreignIDnode

Each layer becomes a <graph> whose id is its namespace, with edgedefault="undirected".

Apply​

onmsctl apply -f examples/graph.yaml --dry-run --diff
onmsctl apply -f examples/graph.yaml

Expected output:

warning: Graph wan-overview: vertex ber-rtr-01: node wan:ber-rtr-01 not found
warning: Graph wan-overview: vertex ber-sw-01: node wan:ber-sw-01 not found
warning: Graph wan-overview: vertex ham-rtr-01: node wan:ham-rtr-01 not found
+-------+--------------+--------+---------+---------+
| kind | name | action | status | message |
+===================================================+
| Graph | wan-overview | create | Created | created |
+-------+--------------+--------+---------+---------+
  • A new graph is uploaded with one POST.
  • A changed graph is replaced: DELETE, a wait until the old container has left /api/v2/graphs, then POST. The server has no update call, and a POST right after the DELETE is stored but never shown.
  • A graph that matches the document sends no write.
  • After every write, apply waits up to 30 seconds for the container to appear in /api/v2/graphs. A slow load prints a warning and does not fail the apply.
  • Apply never deletes a graph. Remove one with graph delete.

Rollback: if the POST of an update fails, apply re-uploads the version it read during the plan. The outcome is Failed and says whether the rollback worked.

Plan gates: every check below runs before any write. One failure aborts the whole apply.

  • Each document passes the field rules above.
  • metadata.name and every namespace are unique within the apply.
  • No namespace belongs to another container on the server. A graph whose namespace is already taken is stored but never loads, without any error from the server.

Order: Graph applies after DataCollectionSource and before BusinessService. It has no dependency on other kinds. Node references are checked while planning, before any kind executes, so a requisition in the same apply still produces not found warnings on its first run.

Diff​

--diff prints the change as a unified YAML diff per graph.

onmsctl apply -f graph.yaml --dry-run --diff

Expected output:

Graph/wan-overview: update
@@ -17,7 +17,7 @@
label: Berlin
iconKey: cloud
- id: site-hamburg
- label: Hamburg
+ label: Hamburg HQ
iconKey: cloud
edges:
- source: site-berlin

A graph uploaded without containerId also shows container id: <old> -> <name>.

Inspect and delete​

onmsctl graph list
onmsctl graph get wan-overview
onmsctl graph export wan-overview > wan-overview.yaml
onmsctl graph view wan-overview wan:sites --focus site-berlin --szl 1
onmsctl graph search wan:sites Ber
onmsctl graph delete wan-overview

Expected output of graph list:

+--------------+--------------------------+--------+---------+
| ID | LABEL | LAYERS | MANAGED |
+============================================================+
| application | Application Graph | 1 | no |
|--------------+--------------------------+--------+---------|
| bsm | Business Service Graph | 1 | no |
|--------------+--------------------------+--------+---------|
| enlinkd | Enlinkd Graphs | 11 | no |
|--------------+--------------------------+--------+---------|
| pathoutage | Path Outage | 1 | no |
|--------------+--------------------------+--------+---------|
| vmware | VMware Topology Provider | 1 | no |
|--------------+--------------------------+--------+---------|
| wan-overview | WAN Overview | 2 | yes |
+--------------+--------------------------+--------+---------+
CommandKindDoes
graph listreadEvery container in /api/v2/graphs. MANAGED is yes when a GraphML upload has the same name.
graph get NAMEreadThe upload as a kind: Graph document, in YAML, or JSON with -o json.
graph export NAMEreadThe upload as an apply-ready kind: Graph document. Edge ids equal to <source>-<target> are omitted.
graph convert -f FILEread, localA GraphML file as a kind: Graph document. No server access.
graph view CONTAINER NAMESPACEreadOne layer as the v2 API serves it. --focus ID (repeatable) takes vertex ids of that layer; --szl N sets the semantic zoom level.
graph search NAMESPACE TEXTreadVertex suggestions within one layer.
graph delete NAMEwriteDeletes the upload. A missing graph exits non-zero with graph NAME not found.

view and search print YAML by default and JSON with -o json. Pass --focus the bare vertex id, such as site-berlin. The namespace:id form finds nothing when the namespace contains a colon.

Migrate a GraphML file​

Convert an existing GraphML file, review it, then apply it.

onmsctl graph convert -f topology.xml > topology.yaml
onmsctl apply -f topology.yaml --dry-run --diff
onmsctl apply -f topology.yaml
  • The document is named after the file's containerId, or its first <graph id> when there is none. That is the container id the server uses for the file today.
  • Rename metadata.name to the name the file was uploaded under (rest/graphml/{name}) before applying. Otherwise the plan fails with already belongs to container, because the old upload still owns the namespaces.
  • Apply always writes containerId: <metadata.name>. A file uploaded without one moves to the new container id on the first apply. Update links to /api/v2/graphs/<old id>.
  • convert prints a warning for each value it drops or rewrites, such as a key the model does not know or a numeric nodeID.
  • The legacy value vertex-status-provider: true is read as default, with a warning. Check the converted layer if the old file relied on another meaning.

Errors​

MessageProbable causeRecovery
missing field namespace or namespace is requiredA layer has no namespace, or an empty one. The server would store it and never load it.Add namespace.
is declared by more than one GraphTwo documents in the apply use the same namespace.Rename one namespace.
already belongs to containerAnother container on the server uses the namespace. The server would store the graph and never load it.Rename the namespace, or delete the other upload.
namespace ... is declared twiceTwo layers of one document share a namespace.Rename one namespace.
vertex id ... is declared twiceTwo vertices share an id, in the same or different layers.Make vertex ids unique across the document.
is not a vertex of layerAn edge is declared in a layer that does not contain its source.Move the edge to its source vertex's layer.
unknown targetAn edge targets a vertex no layer declares.Fix target, or add the vertex.
is declared twice; set an explicit idTwo edges share an id, often two edges between the same pair without id.Set id on one edge.
focus.vertices requires strategy SPECIFICfocus.vertices with another strategy.Set strategy: SPECIFIC, or drop vertices.
strategy SPECIFIC requires focus.verticesSPECIFIC without vertices.List the focus vertices.
focus vertex ... is not in layerA focus vertex belongs to another layer.Focus vertices of the same layer.
must not contain a commaA focus vertex id contains a comma. GraphML joins focus ids with commas.Rename the vertex.
foreignSource and foreignId must both be non-emptyA node reference is incomplete.Set both fields.
name must match [A-Za-z0-9._-]+metadata.name has another character. It is a URL path segment.Rename the graph.
duplicate Graph metadata.nameTwo documents share a name.Rename or remove one document.
node ... not found (warning)No node has that foreign source and foreign id yet. The vertex shows no status.Fix the reference, or apply the requisition.
node ... lookup failed (warning)The node lookup returned an error other than not found.Check the server; the reference is written unchanged.
stored upload: ... was dropped (warning)The stored upload carries keys the model does not know. The update replaces it without them.Keep the keys by not applying, or accept the loss.
derived metadata.name ... is not a valid upload name (warning)convert named the document after a <graph id> that is not path-safe.Set metadata.name to the upload name before applying.
not visible in api/v2/graphs after (warning)The upload is stored but has not loaded.Check karaf.log for GraphML errors.
still listed in api/v2/graphs ... after DELETE (warning)The old version did not unload in time.Run onmsctl graph view to check, and apply again if the old version shows.
appeared since plan; re-run applyAnother client created the graph between plan and execute.Run apply again.
rolled back to the previous versionThe server rejected the new version. The old one is back.Fix the reported error and apply again.
is now absentThe update and its rollback both failed. The graph is deleted.Fix the reported error and apply again to recreate it.
graph ... not foundget, export or delete names no upload.Check the name with graph list.

Example​

examples/graph.yaml
# A two-layer GraphML topology: WAN sites on top, the devices of each site
# below. Applied to rest/graphml/wan-overview and shown in the topology UI as
# container "wan-overview". Vertices with a `node` show that node's alarm
# status; a node that does not exist yet only produces a warning.
apiVersion: graphml.opennms.org/v1
kind: Graph
metadata:
name: wan-overview
spec:
label: WAN Overview
description: Sites and their edge devices
breadcrumbStrategy: SHORTEST_PATH_TO_ROOT
layers:
- namespace: wan:sites
label: Sites
focus:
strategy: ALL
vertexStatusProvider: propagate
vertices:
- id: site-berlin
label: Berlin
iconKey: cloud
- id: site-hamburg
label: Hamburg
iconKey: cloud
edges:
- source: site-berlin
target: site-hamburg
tooltip: MPLS 1 Gbit/s
# Cross-layer edges drill down from a site to its devices.
- source: site-berlin
target: ber-rtr-01
- source: site-hamburg
target: ham-rtr-01
- namespace: wan:devices
label: Devices
focus:
strategy: ALL
vertexStatusProvider: default
vertices:
- id: ber-rtr-01
label: ber-rtr-01
iconKey: router
node: { foreignSource: wan, foreignId: ber-rtr-01 }
- id: ber-sw-01
label: ber-sw-01
iconKey: switch
node: { foreignSource: wan, foreignId: ber-sw-01 }
- id: ham-rtr-01
label: ham-rtr-01
iconKey: router
node: { foreignSource: wan, foreignId: ham-rtr-01 }
edges:
- source: ber-rtr-01
target: ber-sw-01