- New notification script (incidentio-notification.sh) that POSTs JSON
payloads to incident.io HTTP alert sources via curl/jq
- New Icinga2 config template defining User, NotificationCommand (host
+ service), and apply Notification rules — follows the PagerDuty
pattern with opt-in via vars.enable_incidentio
- Notification type mapping: PROBLEM/DOWN/CRITICAL/WARNING/UNKNOWN →
firing, RECOVERY/UP/OK → resolved, ACKNOWLEDGEMENT → firing with
metadata
- Deduplication keys: host-{name} for hosts, service-{host}-{service}
for services
- Deployed via Ansible: script copied to /etc/icinga2/scripts/,
config rendered to conf.d/; gated on icinga2_incidentio_token being
defined
110 lines
2.5 KiB
Django/Jinja
110 lines
2.5 KiB
Django/Jinja
{% if icinga2_incidentio_token is defined and icinga2_incidentio_endpoint_url is defined %}
|
|
|
|
object User "incidentio" {
|
|
display_name = "incident.io"
|
|
groups = [ "icingaadmins" ]
|
|
|
|
vars.token = {{ icinga2_incidentio_token | to_json }}
|
|
vars.endpoint_url = {{ icinga2_incidentio_endpoint_url | to_json }}
|
|
|
|
states = [ OK, Warning, Critical, Unknown, Up, Down ]
|
|
types = [ Problem, Acknowledgement, Recovery ]
|
|
}
|
|
|
|
object NotificationCommand "notify-service-by-incidentio" {
|
|
import "plugin-notification-command"
|
|
|
|
command = [ ConfigDir + "/scripts/incidentio-notification.sh" ]
|
|
|
|
arguments = {
|
|
"--endpoint-url" = {
|
|
value = "$user.vars.endpoint_url$"
|
|
order = 0
|
|
}
|
|
"--token" = {
|
|
value = "$user.vars.token$"
|
|
order = 1
|
|
}
|
|
"--title" = {
|
|
value = "$service.name$ on $host.display_name$ is $service.state$"
|
|
order = 2
|
|
}
|
|
"--description" = {
|
|
value = "$service.output$"
|
|
order = 3
|
|
}
|
|
"--dedup-key" = {
|
|
value = "service-$host.name$-$service.name$"
|
|
order = 4
|
|
}
|
|
"--status" = {
|
|
value = "$notification.type$"
|
|
order = 5
|
|
}
|
|
"--host" = {
|
|
value = "$host.name$"
|
|
order = 6
|
|
}
|
|
"--service" = {
|
|
value = "$service.name$"
|
|
order = 7
|
|
}
|
|
}
|
|
}
|
|
|
|
object NotificationCommand "notify-host-by-incidentio" {
|
|
import "plugin-notification-command"
|
|
|
|
command = [ ConfigDir + "/scripts/incidentio-notification.sh" ]
|
|
|
|
arguments = {
|
|
"--endpoint-url" = {
|
|
value = "$user.vars.endpoint_url$"
|
|
order = 0
|
|
}
|
|
"--token" = {
|
|
value = "$user.vars.token$"
|
|
order = 1
|
|
}
|
|
"--title" = {
|
|
value = "Host $host.display_name$ is $host.state$"
|
|
order = 2
|
|
}
|
|
"--description" = {
|
|
value = "$host.output$"
|
|
order = 3
|
|
}
|
|
"--dedup-key" = {
|
|
value = "host-$host.name$"
|
|
order = 4
|
|
}
|
|
"--status" = {
|
|
value = "$notification.type$"
|
|
order = 5
|
|
}
|
|
"--host" = {
|
|
value = "$host.name$"
|
|
order = 6
|
|
}
|
|
}
|
|
}
|
|
|
|
apply Notification "incidentio-service" to Service {
|
|
command = "notify-service-by-incidentio"
|
|
states = [ OK, Warning, Critical, Unknown ]
|
|
types = [ Problem, Acknowledgement, Recovery ]
|
|
period = "24x7"
|
|
users = [ "incidentio" ]
|
|
assign where service.vars.enable_incidentio == true
|
|
}
|
|
|
|
apply Notification "incidentio-host" to Host {
|
|
command = "notify-host-by-incidentio"
|
|
states = [ Up, Down ]
|
|
types = [ Problem, Acknowledgement, Recovery ]
|
|
period = "24x7"
|
|
users = [ "incidentio" ]
|
|
assign where host.vars.enable_incidentio == true
|
|
}
|
|
|
|
{% endif %}
|