diff options
author | Toby Hammond <tobydecks@gmail.com> | 2021-02-11 12:22:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-11 07:22:18 -0500 |
commit | 877a17b845780957c7e2a6250c389d7911a9bbde (patch) | |
tree | 8effc6d1e86e6c933ed95f3dbfca9a30094c1d8f /health | |
parent | 262329b2eabe67f4500e4ea33615d46c45c20fab (diff) |
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
Diffstat (limited to 'health')
-rwxr-xr-x | health/notifications/alarm-notify.sh.in | 4 | ||||
-rwxr-xr-x | health/notifications/health_alarm_notify.conf | 1 | ||||
-rw-r--r-- | health/notifications/opsgenie/README.md | 6 |
3 files changed, 8 insertions, 3 deletions
diff --git a/health/notifications/alarm-notify.sh.in b/health/notifications/alarm-notify.sh.in index 456e20cc5d..b4127bf6b7 100755 --- a/health/notifications/alarm-notify.sh.in +++ b/health/notifications/alarm-notify.sh.in @@ -411,6 +411,8 @@ else done fi +OPSGENIE_API_URL=${OPSGENIE_API_URL:-"https://api.opsgenie.com"} + # If we didn't autodetect the character set for e-mail and it wasn't # set by the user, we need to set it to a reasonable default. UTF-8 # should be correct for almost all modern UNIX systems. @@ -2179,7 +2181,7 @@ send_opsgenie() { EOF ) - httpcode=$(docurl -X POST -H "Content-Type: application/json" -d "${payload}" "https://api.opsgenie.com/v1/json/integrations/webhooks/netdata?apiKey=${OPSGENIE_API_KEY}") + httpcode=$(docurl -X POST -H "Content-Type: application/json" -d "${payload}" "${OPSGENIE_API_URL}/v1/json/integrations/webhooks/netdata?apiKey=${OPSGENIE_API_KEY}") # https://docs.opsgenie.com/docs/alert-api#create-alert if [ "${httpcode}" = "200" ]; then info "sent opsgenie notification for: ${host} ${chart}.${name} is ${status}" diff --git a/health/notifications/health_alarm_notify.conf b/health/notifications/health_alarm_notify.conf index 827a47d998..be669e135d 100755 --- a/health/notifications/health_alarm_notify.conf +++ b/health/notifications/health_alarm_notify.conf @@ -284,6 +284,7 @@ SEND_OPSGENIE="YES" # Api key OPSGENIE_API_KEY="" +OPSGENIE_API_URL="" DEFAULT_RECIPIENT_OPSGENIE="" diff --git a/health/notifications/opsgenie/README.md b/health/notifications/opsgenie/README.md index aeb3154896..7ae409df4a 100644 --- a/health/notifications/opsgenie/README.md +++ b/health/notifications/opsgenie/README.md @@ -20,14 +20,16 @@ directory](/docs/configure/nodes.md): ./edit-config health_alarm_notify.conf ``` -Change the variable `OPSGENIE_API_KEY` with the API key you got from Opsgenie. +Change the variable `OPSGENIE_API_KEY` with the API key you got from Opsgenie. +`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. ``` SEND_OPSGENIE="YES" # Api key -# Default Opsgenie APi +# Default Opsgenie API OPSGENIE_API_KEY="11111111-2222-3333-4444-555555555555" +OPSGENIE_API_URL="" ``` Changes to `health_alarm_notify.conf` do not require a Netdata restart. You can test your Opsgenie notifications |