Skip to main content

ThresholdGroup

Declare one threshold group per document: its basic thresholds and its expression thresholds. Targets /api/v2/thresholding. Requires Horizon 37.0.0 (NMS-19837). Older servers fail with a version error.

A group does nothing on its own. A ThreshdPackage service binds it to interfaces.

YAML​

FieldTypeDefaultDescription
apiVersionstringrequiredthresholding.opennms.org/v1
kindstringrequiredThresholdGroup
metadata.namestringrequiredGroup name. Packages bind the group by this name.
spec.rrdRepositorystringrequiredDirectory holding the RRD files the group thresholds against.
spec.thresholdslist[]Basic thresholds on one datasource each, in evaluation order.
spec.expressionslist[]Thresholds on an expression over datasources, in evaluation order.

Fields of a threshold or expression entry:

FieldTypeDefaultDescription
typestringrequiredhigh, low, relativeChange, absoluteChange or rearmingAbsoluteChange.
dsTypestringrequirednode, if, or a generic resource type known to the server.
dsNamestringrequired on thresholdsCollected datasource, at most 19 characters.
expressionstringrequired on expressionsExpression over datasource names.
valuenumber or stringrequiredTrigger value. A string can hold a metadata reference such as ${requisition:cpu-high|90}.
rearmnumber or stringrequiredRe-arm value. Unused for relativeChange, still required.
triggerinteger or stringrequiredConsecutive polls before triggering: a positive integer or a ${…} reference.
descriptionstringnoneFree text.
dsLabelstringnoneString attribute used to label the resource in events.
exprLabelstringnoneLabel for an expression threshold.
triggeredUEIstringstandard threshold UEIEvent sent on trigger. An unknown UEI is created on the server from the built-in threshold event.
rearmedUEIstringstandard UEIEvent sent on re-arm. Ignored for relativeChange and absoluteChange.
filterOperatorstringorHow several resource filters combine: and or or.
relaxedbooleanfalseEvaluate even when some referenced values are unknown.
resourceFilterslist[]{field, content} Java regular expressions on resource fields. Ignored for dsType: node.

Apply​

onmsctl apply -f ./thresholds/ --dry-run --diff
onmsctl apply -f ./thresholds/
  • Apply creates an absent group and replaces a changed one.
  • It leaves a matching group untouched and sends no request, because every write reloads threshd.
  • Updates carry the ETag read during plan, so a group changed on the server in between fails instead of being overwritten.
  • Apply never deletes. Groups no document declares are left alone.
  • A group contributed by an extension is read-only and fails the plan.

Plan gate: each dsType is checked against the server's list of datasource types before any write. The server itself accepts unknown types, so a typo would otherwise stop the threshold from ever matching.

Order: ThresholdGroup applies after EventSource, so a triggeredUEI can name an event the same apply creates, and before ThreshdPackage.

Diff​

Entries are matched by position, because list order is evaluation order.

ThresholdGroup/acme-cpu: update
~ thresholds[0] high node/cpuPercentBusy: trigger 2 -> 3, value 85 -> 90
+ expressions[1] high if: ifHCOutOctets * 8 / 1000000 / ifHighSpeed * 100
- thresholds[2] low node/memAvailReal

Inspect, export and delete​

onmsctl threshold group list
onmsctl threshold group get mib2 > threshold-group-mib2.yaml
onmsctl threshold export --out ./thresholds/
onmsctl threshold group delete acme-cpu
  • get and export write documents that apply back unchanged. Values stay the server's strings, quoted, such as value: '1.0'.
  • export --out <dir> writes every group and package, one file each, and skips extension groups. It refuses to overwrite existing files unless you pass --force. Without --out it writes one ----separated stream to stdout.
  • group delete refuses while a package still binds the group. --force deletes anyway and leaves the package with a dangling reference.

Errors​

MessageProbable causeRecovery
does not expose the threshold REST APIThe server predates NMS-19837.Upgrade to Horizon 37.0.0 or later.
dsType '<x>' is not a datasource type on this serverA typo, or a resource type not configured in datacollection-config.xml.Fix dsType; list valid types with GET /api/v2/thresholding/metadata.
dsName '<x>' is longer than 19 charactersRRDtool cannot store longer datasource names.Use the collected datasource's real name.
contributed by an extension and cannot be managedThe group comes from an OSGi extension.Remove the document.
changed on the server since planSomeone edited the group between plan and write.Re-run the apply.

Example​

examples/threshold-group.yaml
# ThresholdGroup: one threshold group with its thresholds and expressions.
#
# List order is evaluation order. value, rearm and trigger take a number or
# a string, e.g. a metadata reference like ${requisition:cpu-high|90}.
# dsType must be a datasource type the server knows: node, if, or a generic
# resource type (see GET /api/v2/thresholding/metadata).
# Requires Horizon 37.0.0 (NMS-19837).
#
# onmsctl apply -f examples/threshold-group.yaml --dry-run --diff
#
apiVersion: thresholding.opennms.org/v1
kind: ThresholdGroup
metadata:
name: acme-cpu
spec:
rrdRepository: /opt/opennms/share/rrd/snmp/
thresholds:
- type: high
dsType: node
dsName: cpuPercentBusy
value: 90
rearm: 80
trigger: 3
description: CPU above 90% for three polls
expressions:
- type: high
dsType: if
expression: ifHCInOctets * 8 / 1000000 / ifHighSpeed * 100
value: 90
rearm: 75
trigger: 2
dsLabel: ifName
description: Inbound utilisation above 90%
resourceFilters:
- field: ifHighSpeed
content: "^[1-9]+[0-9]*$"