@cryptotaxi247 / netdata-1 / commits / 877a17b84

health: make Opsgenie API URL configurable (#10561)

* Update health_alarm_notify.conf Add OPSGENIE_API_URL="" to specify API endpoint * Update health_alarm_notify.conf Add URL for sanity * Update alarm-notify.sh.in Add default value of https://api.opsgenie.com for OPSGENIE_API_URL when unset Substitute OPSGENIE_API_URL for URL on line 2182 * Update alarm-notify.sh.in Re-added parenthesis deleted in error on ln 2180 * Update README.md Amend to reflect OPSGENIE_API_URL variable * Update health_alarm_notify.conf Remove hardcoded URL as now has default if unset * Update alarm-notify.sh.in Moved OPSGENIE_API_URL=${OPSGENIE_API_URL:-"https://api.opsgenie.com"} from line 394 to line 415 as per comment https://github.com/netdata/netdata/pull/10561#discussion_r568430266

Toby Hammond committed Feb 11, 2021 at 12:22 UTC 877a17b845780957c7e2a6250c389d7911a9bbde
3 files changed +8 -3
health/notifications/alarm-notify.sh.in
+3 -1
@@ -411,6 +411,8 @@ else
411 done
412 fi
413
414 +OPSGENIE_API_URL=${OPSGENIE_API_URL:-"https://api.opsgenie.com"}
415 +
416 # If we didn't autodetect the character set for e-mail and it wasn't
417 # set by the user, we need to set it to a reasonable default. UTF-8
418 # should be correct for almost all modern UNIX systems.
@@ -2179,7 +2181,7 @@ send_opsgenie() {
2181 EOF
2182 )
2183
2182 - httpcode=$(docurl -X POST -H "Content-Type: application/json" -d "${payload}" "https://api.opsgenie.com/v1/json/integrations/webhooks/netdata?apiKey=${OPSGENIE_API_KEY}")
2184 + httpcode=$(docurl -X POST -H "Content-Type: application/json" -d "${payload}" "${OPSGENIE_API_URL}/v1/json/integrations/webhooks/netdata?apiKey=${OPSGENIE_API_KEY}")
2185 # https://docs.opsgenie.com/docs/alert-api#create-alert
2186 if [ "${httpcode}" = "200" ]; then
2187 info "sent opsgenie notification for: ${host} ${chart}.${name} is ${status}"
health/notifications/health_alarm_notify.conf
+1
@@ -284,6 +284,7 @@ SEND_OPSGENIE="YES"
284
285 # Api key
286 OPSGENIE_API_KEY=""
287 +OPSGENIE_API_URL=""
288
289 DEFAULT_RECIPIENT_OPSGENIE=""
290
health/notifications/opsgenie/README.md
+4 -2
@@ -20,14 +20,16 @@ directory](/docs/configure/nodes.md):
20 ./edit-config health_alarm_notify.conf
21 ```
22
23 -Change the variable `OPSGENIE_API_KEY` with the API key you got from Opsgenie.
23 +Change the variable `OPSGENIE_API_KEY` with the API key you got from Opsgenie.
24 +`OPSGENIE_API_URL` defaults to https://api.opsgenie.com, however there are region specific API URLs such as https://eu.api.opsgenie.com, so set this if required.
25
26 ```
27 SEND_OPSGENIE="YES"
28
29 # Api key
29 -# Default Opsgenie APi
30 +# Default Opsgenie API
31 OPSGENIE_API_KEY="11111111-2222-3333-4444-555555555555"
32 +OPSGENIE_API_URL=""
33 ```
34
35 Changes to `health_alarm_notify.conf` do not require a Netdata restart. You can test your Opsgenie notifications