Skip to main content

BusinessService

Declare one Business Service Monitoring (BSM) service per document. A service has attributes, a reduce function and four kinds of edge: child services, monitored IP services, applications and raw alarm reduction keys. Each edge has a weight and an optional map function. Targets /api/v2/business-services. See the compatibility table for supported servers.

YAML​

BusinessService is named and multi-instance: metadata.name is the service name. Unknown fields are rejected.

FieldTypeDefaultDescription
apiVersionstringrequiredbsm.opennms.org/v1
kindstringrequiredBusinessService
metadata.namestringrequiredService name. Must not be empty. Must be unique within an apply.
spec.attributesmap of string to string{}Free-form key/value attributes.
spec.reduceFunctionfunction{type: HighestSeverity}How edge severities aggregate into the service status.
spec.childServiceslist of child edges[]Edges to other Business Services.
spec.ipServiceslist of IP service edges[]Edges to monitored services on a node interface.
spec.applicationslist of application edges[]Edges to OpenNMS Applications.
spec.reductionKeyslist of reduction-key edges[]Edges to raw alarm reduction keys.

References are by name. The BSM REST API is ID-centric, so onmsctl resolves names to ids at apply. The same YAML is portable across instances.

Functions​

A reduce or map function is a type plus string-valued properties.

FieldTypeDefaultDescription
typestringrequiredFunction name, from the tables below.
propertiesmap of string to string{}Parameters the function needs. Quote numbers, such as threshold: "0.75".

Reduce functions, for spec.reduceFunction:

TypeRequired propertiesValidation
HighestSeveritynoneDefault when reduceFunction is omitted.
ThresholdthresholdA number in (0, 1].
HighestSeverityAbovethresholdA status: Indeterminate, Normal, Warning, Minor, Major or Critical.
ExponentialPropagationbaseA number greater than 1.0.

Map functions, for an edge's mapFunction:

TypeRequired propertiesValidation
IdentitynoneDefault when mapFunction is omitted.
Increasenone
Decreasenone
Ignorenone
SetTostatusA status: Indeterminate, Normal, Warning, Minor, Major or Critical.

Status names are case-insensitive.

Edges​

Every edge type has these two fields:

FieldTypeDefaultDescription
weightinteger1Edge weight. Must be >= 1.
mapFunctionfunction{type: Identity}Severity transform for this edge.

childServices entries:

FieldTypeDefaultDescription
namestringrequiredName of another Business Service. It must exist on the server or be a document in the same apply.

ipServices entries:

FieldTypeDefaultDescription
nodenode referencerequiredThe node that hosts the service.
ipAddressstringrequiredInterface IP address. Must parse as an IPv4 or IPv6 address.
servicestringrequiredMonitored service name, such as HTTP. Must not be empty.
friendlyNamestringnoneDisplay name for the edge.

applications entries:

FieldTypeDefaultDescription
namestringrequiredName of an OpenNMS Application on the server.

reductionKeys entries:

FieldTypeDefaultDescription
reductionKeystringrequiredAlarm reduction key. Must not be empty. May contain {{token}} placeholders.
nodenode referencenoneNode that expands the tokens. Required when the key has a token. An error when the key has none.
friendlyNamestringnoneDisplay name for the edge.

Node references​

A node reference uses exactly one of two forms.

FieldTypeDefaultDescription
labelstringrequired in the label formNode label. Must not be empty.
locationstringDefaultMonitoring location. Only valid in the label form.
foreignSourcestringrequired in the foreign formRequisition name. Must not be empty.
foreignIdstringrequired in the foreign formNode foreign ID. Must not be empty.

Mixing label with foreignSource or foreignId is an error. Labels are not unique in OpenNMS. A label that matches more than one node in the location fails the apply. Use {foreignSource, foreignId} when a label is not unique.

Reduction-key templates​

A reductionKey can contain these tokens, matched case-insensitively:

TokenNeeds node formExpands to
{{nodeId}}eitherThe numeric node id, resolved at apply.
{{foreignSource}}{foreignSource, foreignId}The reference's foreignSource.
{{foreignId}}{foreignSource, foreignId}The reference's foreignId.
{{nodeLabel}}{label, location}The reference's label.

Any other token is an error. A token that the node form cannot supply fails at plan, before any request.

Prefer ipServices over hand-written reduction keys. An ipServices edge needs no node id. It follows the service's standard alarms, such as nodeLostService, interfaceDown and nodeDown (Horizon behaviour). Use reductionKeys for custom alarms: thresholds, custom UEIs and situations. The expanded key must match a real alarm's reduction key. Copy it from a real alarm, not from the event definition's formula.

Apply​

onmsctl apply -f examples/business-service.yaml --dry-run --diff
onmsctl apply -f examples/business-service.yaml
  • Apply reconciles each service as a whole object.
  • A new service is created, then fully replaced with a PUT.
  • A changed service is fully replaced with a PUT. Edges omitted from the document are removed.
  • A service that matches the document sends no write. Edge order does not matter.
  • Apply never deletes a service. A service on the server but absent from the apply stays. Remove it with business-service delete.

Two-pass execute: pass 1 creates each new service with its name, attributes and reduce function only. Pass 2 PUTs the full body, with every edge resolved to an id. Two new services can reference each other's names in one file, in any order.

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

  • metadata.name is unique within the apply.
  • Each document passes the field validation above.
  • Child references form no cycle among the applied services.
  • Every application, node, monitored service and child service resolves on the server or in the apply.

Daemon reload: changes stay inert until bsmd reloads. After any successful write, apply sends one POST /api/v2/business-services/daemon/reload. A failed reload does not fail the apply. It prints a warning that names the reload endpoint. Reload bsmd by hand.

Order: BusinessService applies last, after Graph. It has no cross-kind dependencies. The two-pass execute orders child references within the kind.

Diff​

--diff prints one fixed reconcile note for the kind. It shows no per-field changes. The per-service action (create, update or unchanged) appears in the apply output.

business-service: each service is reconciled as a whole object (create / full PUT). Edges omitted from a document are pruned; a service present on the server but absent from this apply is NOT deleted (use `onmsctl business-service delete <name>`).

Inspect and delete​

onmsctl business-service list
onmsctl bs list
onmsctl business-service get web-frontend
onmsctl business-service delete web-frontend

Expected output:

$ onmsctl business-service list
+------+----------+-------------+--------------+----------------+
| NAME | CHILDREN | IP-SERVICES | APPLICATIONS | REDUCTION-KEYS |
+===============================================================+
+------+----------+-------------+--------------+----------------+
  • bs is an alias for business-service.
  • list prints one row per service with its edge counts: NAME, CHILDREN, IP-SERVICES, APPLICATIONS and REDUCTION-KEYS.
  • get <name> prints the same row for one service.
  • delete <name> removes the service, then reloads bsmd.
  • If the reload fails after the delete, delete prints a warning and exits successfully. Reload bsmd by hand.

Errors​

MessageProbable causeRecovery
is ambiguousThe node label matches more than one node in the location.Use a {foreignSource, foreignId} node reference.
no node matches labelNo node has that label in the location. The location defaults to Default.Fix label, or set location.
not found (not on the server and not in this apply)A childServices name is unknown.Fix the name, or add the child's document to the apply.
child references form a cycleServices in the apply reference each other in a loop.Remove one child edge from the loop.
names must be unique within an applyTwo documents share a metadata.name.Rename or remove one document.
unsupported template tokenThe reduction key uses a token other than nodeId, foreignSource, foreignId or nodeLabel.Use a supported token, or write the value literally.
requires a {foreignSource, foreignId} node reference{{foreignSource}} or {{foreignId}} with a label-form node.Switch the node to {foreignSource, foreignId}.
requires a {label, location} node reference{{nodeLabel}} with a foreign-form node.Switch the node to {label, location}, or drop the token.
no `node` reference was given to resolve itThe reduction key has a token but the edge has no node.Add node.
contains no {{token}} to expandThe edge has a node but the key has no token.Remove node, or add the token.
weight must be >= 1An edge has weight 0 or negative.Set weight to 1 or more.
mapFunction SetTo requires a `status` propertySetTo without properties.status.Add status, such as Major.
is not a known reduce functionA typo in reduceFunction.type.Use a type from the reduce function table.
threshold must be in (0, 1]Threshold with a value outside the range.Use a fraction such as "0.75".
base must be > 1.0ExponentialPropagation with a base of 1 or less.Use a base greater than 1.
not found (resolve to an id failed)No Application with that name on the server.Create the Application, or fix the name.
monitored serviceThe node has no such service on that IP.Fix ipAddress or service, or provision the service.
bsmd daemon/reload failedThe write succeeded but the reload call failed. The changes are inert.Reload bsmd with POST /api/v2/business-services/daemon/reload.

Example​

examples/business-service.yaml
# A Business Service exercising all four edge types. References are by name and
# resolved to numeric ids at apply time (BSM's REST API is ID-centric). See
# README "Business services (kind: BusinessService)".
apiVersion: bsm.opennms.org/v1
kind: BusinessService
metadata:
name: web-frontend
spec:
attributes:
owner: platform-team
tier: "1"

# Per-service reduce function: how edge severities aggregate into the
# service's operational status. Exactly one.
reduceFunction:
type: Threshold # HighestSeverity | Threshold | HighestSeverityAbove | ExponentialPropagation
properties:
threshold: "0.75" # fraction in (0,1]

# → another Business Service, by name.
childServices:
- name: database-tier
weight: 2
mapFunction:
type: Increase # Identity | Increase | Decrease | Ignore | SetTo

# → a monitored IP service. The node is resolved by label + location; this
# auto-covers the service's standard alarms (nodeLostService/interfaceDown/
# nodeDown). No hand-written reduction key is needed.
ipServices:
- node:
label: webhost01
location: Default # optional; defaults to "Default"
ipAddress: 10.0.0.10
service: HTTP
friendlyName: web-http
weight: 1
mapFunction:
type: Identity

# → an OpenNMS Application, by name.
applications:
- name: Webservers
weight: 1

# → a raw alarm reduction key (escape hatch for custom alarms). Only {{nodeId}}
# is templated from the node reference; the rest is the threshold's own
# reduction-key signature, typed verbatim.
reductionKeys:
- node:
foreignSource: networking
foreignId: dist-sw-01
reductionKey: "uei.opennms.org/threshold/highThresholdExceeded::{{nodeId}}:10.42.0.130:ifHCInOctets * 8 / 1000000 / ifHighSpeed * 100:90.0:3:75.0:Gi1/0/47"
friendlyName: uplink-saturation
weight: 1
mapFunction:
type: SetTo
properties:
status: Major