Skip to content

Instantly share code, notes, and snippets.

@j-white
Last active January 12, 2022 15:37
Show Gist options
  • Save j-white/d5d0b157c28ff104983da658493fcacf to your computer and use it in GitHub Desktop.
Save j-white/d5d0b157c28ff104983da658493fcacf to your computer and use it in GitHub Desktop.
ALEC Demo

Provision a new node 'n1' using the Quick Add workflow.

Create a link between 'localhost' and 'n1' with a POST to /api/v2/userdefinedlinks

{
  "node-id-a": 1,
  "node-id-z": 2,
  "component-label-a": "port-a",
  "component-label-z": "port-z",
  "link-id": "localhost:port-a->n1:port-z",
  "owner": "me"
}

View the relation in topology.

Create an alarm on n1 with a POST to /api/v2/events:

{
 "uei": "uei.opennms.org/alarms/trigger",
 "nodeid": 2,
 "parms": [
   {"parmName": "node", "value": "sometimes"},
   {"parmName": "ip", "value": "things"},
   {"parmName": "service", "value": "fail"}
 ],
 "severity": "minor"
}

Create an alarm on localhost with a POST to /api/v2/events:

{
 "uei": "uei.opennms.org/alarms/trigger",
 "nodeid": 1,
 "parms": [
   {"parmName": "node", "value": "sometimes"},
   {"parmName": "ip", "value": "things"},
   {"parmName": "service", "value": "break"}
 ],
 "severity": "major"
}

See if the situation was created.

Alternative create it manually with with a POST to /api/v2/events

{
 "uei": "uei.opennms.org/alarms/situation",
 "parms": [
   {"parmName": "related-reductionKey", "value": "uei.opennms.org/alarms/trigger:sometimes:things:fail"},
   {"parmName": "related-reductionKey", "value": "uei.opennms.org/alarms/trigger:sometimes:things:break"}
 ]
}

In Grafana, create a new panel with Data Source OpenNMS Entities and the Alarm Table visualization with query SELECT Alarms WHERE isSituation = true OR isInSituation = false. Add Situation Alarm Count as a column.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment