Skip to content

Instantly share code, notes, and snippets.

@justynroberts
Created October 24, 2024 11:01
Show Gist options
  • Save justynroberts/6ca00fbe6be96993d698e115f3ac00ec to your computer and use it in GitHub Desktop.
Save justynroberts/6ca00fbe6be96993d698e115f3ac00ec to your computer and use it in GitHub Desktop.
Sample Node-Red Flow for OPC-UA to PagerDuty Events
[
{
"id": "be12058e8765348e",
"type": "switch",
"z": "d7d5b52d.77f328",
"name": "Check Status",
"property": "payload.value",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "Fault",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 360,
"y": 440,
"wires": [
[
"4683d2409da87196"
]
]
},
{
"id": "b52bdd48a3ef3683",
"type": "OpcUa-Event",
"z": "d7d5b52d.77f328",
"root": "OPC-Server",
"activatecustomevent": false,
"eventtype": "i=2052",
"customeventtype": "",
"name": "ProblemQueue",
"x": 160,
"y": 440,
"wires": [
[
"be12058e8765348e"
]
]
},
{
"id": "5d1869a1f6cc4a87",
"type": "OpcUa-Client",
"z": "d7d5b52d.77f328",
"endpoint": "",
"action": "read",
"deadbandtype": "a",
"deadbandvalue": 1,
"time": 10,
"timeUnit": "s",
"certificate": "n",
"localfile": "",
"localkeyfile": "",
"securitymode": "None",
"securitypolicy": "None",
"useTransport": false,
"maxChunkCount": 1,
"maxMessageSize": 8192,
"receiveBufferSize": 8192,
"sendBufferSize": 8192,
"name": "OPC-Server",
"x": 110,
"y": 380,
"wires": [
[],
[
"b52bdd48a3ef3683"
]
]
},
{
"id": "d52692eb466b6df4",
"type": "http request",
"z": "d7d5b52d.77f328",
"name": "PagerDuty Event",
"method": "POST",
"ret": "obj",
"paytoqs": "ignore",
"url": "https://events.pagerduty.com/v2/enqueue",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 830,
"y": 440,
"wires": [
[
"c2a28ac9d7059408"
]
]
},
{
"id": "c2a28ac9d7059408",
"type": "debug",
"z": "d7d5b52d.77f328",
"name": "Webhook Response",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1040,
"y": 440,
"wires": []
},
{
"id": "4683d2409da87196",
"type": "function",
"z": "d7d5b52d.77f328",
"name": "Build PagerDuty Payload",
"func": "msg.payload = {\n \"routing_key\": \"KEYHERE\", // Replace with your integration key\n \"event_action\": \"trigger\", // Could be \"trigger\", \"acknowledge\", or \"resolve\"\n \"payload\": {\n \"summary\": \"Critical: Database is down\", // Short description of the incident\n \"severity\": \"critical\", // Can be: \"critical\", \"error\", \"warning\", or \"info\"\n \"source\": \"database.server1.example.com\", // Hostname or other identifier of the source\n \"component\": \"database\", // Specific component that is affected\n \"group\": \"production\", // A high-level grouping such as deployment environment\n \"class\": \"database\", // Class of the event (e.g., \"database\", \"network\")\n \"custom_details\": {\n \"error_code\": \"DB_CONN_FAILED\", // Any custom information you want to include\n \"error_message\": \"Unable to connect to the database on port 5432\"\n }\n },\n \"dedup_key\": \"unique_incident_key_123\", // Optional. Used to correlate triggers and resolves\n \"images\": [ // Optional. Images related to the incident\n {\n \"src\": \"https://example.com/image1.png\",\n \"href\": \"https://example.com\",\n \"alt\": \"Image of the incident\"\n }\n ],\n \"links\": [ // Optional. Links related to the incident\n {\n \"href\": \"https://example.com/logs\",\n \"text\": \"Detailed log information\"\n }\n ]\n};\n\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 610,
"y": 440,
"wires": [
[
"d52692eb466b6df4"
]
]
},
{
"id": "ae771ac37ca398e2",
"type": "inject",
"z": "d7d5b52d.77f328",
"name": "Testing",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 390,
"y": 380,
"wires": [
[
"4683d2409da87196"
]
]
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment