@cryptotaxi247 / netdata-1 / commits / 7077cd0a8

feat: add OpsGenie alert levels to payload (#14992)

Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud>

OliverNChalk committed May 2, 2023 at 09:25 UTC 7077cd0a8eb974baff7636cc71b16a2ef9dbaac4
1 file changed +10 -1
health/notifications/alarm-notify.sh.in
+10 -1
@@ -2321,7 +2321,7 @@ EOF
2321 # Opsgenie sender
2322
2323 send_opsgenie() {
2324 - local payload httpcode oldv currv
2324 + local payload httpcode oldv currv priority
2325 [ "${SEND_OPSGENIE}" != "YES" ] && return 1
2326
2327 if [ -z "${OPSGENIE_API_KEY}" ] ; then
@@ -2329,6 +2329,14 @@ send_opsgenie() {
2329 return 1
2330 fi
2331
2332 + # Priority for OpsGenie alert (https://support.atlassian.com/opsgenie/docs/update-alert-priority-level/)
2333 + case "${status}" in
2334 + CRITICAL) priority="P1" ;; # Critical is P1
2335 + WARNING) priority="P3" ;; # Warning is P3
2336 + CLEAR) priority="P5" ;; # Clear is P5
2337 + *) priority="P3" ;; # OpsGenie's default alert level is P3
2338 + esac
2339 +
2340 # We are sending null when values are nan to avoid errors while JSON message is parsed
2341 [ "${old_value}" != "nan" ] && oldv="${old_value}" || oldv="null"
2342 [ "${value}" != "nan" ] && currv="${value}" || currv="null"
@@ -2343,6 +2351,7 @@ send_opsgenie() {
2351 "when": ${when},
2352 "name" : "${name}",
2353 "family" : "${family}",
2354 + "priority" : "${priority}",
2355 "status" : "${status}",
2356 "old_status" : "${old_status}",
2357 "value" : ${currv},