- Version used (
icinga2 --r2.13.6-1
) - Operating System and version : debian 12 bookworm
- managed by puppet
- however, for initiate testing just working on single icinga2 server without puppet.
Hi ,
I am trying to integrate icinga2 with pagerduty (go-pdagent)
my pagerduty-icinga2.cfg file is as follow :
object User "pdagent" {
pager = "MY API INTEGRATION KEY "
# groups = [ "icingaadmins" ]
display_name = "PagerDuty Notification User"
states = [ OK, Warning, Critical, Unknown, Up, Down ]
types = [ Problem, Acknowledgement, Recovery ]
}
object NotificationCommand "notify-service-by-pagerduty" {
import "plugin-notification-command"
command = [ "/usr/local/bin/pdagent" ]
arguments = {
"enqueue" = {
skip_key = true
order = 0
value = "enqueue"
}
"-f" = {
order = 1
value = "pd_nagios_object=service"
}
}
env = {
"ICINGA_CONTACTPAGER" = "$user.pager$"
"ICINGA_NOTIFICATIONTYPE" = "$notification.type$"
"ICINGA_SERVICEDESC" = "$service.name$"
"ICINGA_HOSTNAME" = "$host.name$"
"ICINGA_HOSTALIAS" = "$host.display_name$"
"ICINGA_SERVICESTATE" = "$service.state$"
"ICINGA_SERVICEOUTPUT" = "$service.output$"
}
}
object NotificationCommand "notify-host-by-pagerduty" {
import "plugin-notification-command"
command = [ "/usr/local/bin/pdagent" ]
arguments = {
"enqueue" = {
skip_key = true
order = 0
value = "enqueue"
}
"-f" = {
order = 1
value = "pd_nagios_object=host"
}
}
env = {
"ICINGA_CONTACTPAGER" = "$user.pager$"
"ICINGA_NOTIFICATIONTYPE" = "$notification.type$"
"ICINGA_HOSTNAME" = "$host.name$"
"ICINGA_HOSTALIAS" = "$host.display_name$"
"ICINGA_HOSTSTATE" = "$host.state$"
"ICINGA_HOSTOUTPUT" = "$host.output$"
}
}
apply Notification "pagerduty-service" to Service {
command = "notify-service-by-pagerduty"
states = [ OK, Warning, Critical, Unknown ]
types = [ Problem, Acknowledgement, Recovery ]
# period = "24x7"
users = [ "pdagent" ]
assign where service.vars.enable_pagerduty == true
}
apply Notification "pagerduty-host" to Host {
command = "notify-host-by-pagerduty"
states = [ Up, Down ]
types = [ Problem, Acknowledgement, Recovery ]
# period = "24x7"
users = [ "pdagent" ]
assign where host.vars.enable_pagerduty == true
}
and my /etc/pdagent/config.yaml is :
address: 127.0.0.1:49463
database: /var/db/pdagent/pdagent.db
pidfile: /var/run/pdagent/pidfile
region: us
secret: MY API INTEGRATION KEY
logging:
level: debug
the icinga2 logs are :
[2024-04-19 15:58:30 +1000] information/Checkable: Checkable 'icinga01-bom.trellian.com!ssh' has 1 notification(s). Checking filters for type 'Problem', sends will be logged.
[2024-04-19 15:58:30 +1000] information/Notification: Sending 'Problem' notification 'icinga01-bom.trellian.com!ssh!pagerduty-service' for user 'pdagent'
[2024-04-19 15:58:30 +1000] information/Notification: Completed sending 'Problem' notification 'icinga01-bom.trellian.com!ssh!pagerduty-service' for checkable 'icinga01-bom.trellian.com!ssh' and user 'pdagent' using command 'notify-service-by-pagerduty'.
and my pdagent logs are :
"level":"info","ts":1713508896.3805995,"logger":"Heartbeat","caller":"server/heartbeat.go:58","msg":"Starting heartbeat."}
{"level":"info","ts":1713508927.964813,"logger":"Server","caller":"server/middleware.go:12","msg":"Handling request: /send"}
{"level":"error","ts":1713508927.9654932,"logger":"PersistentQueue","caller":"persistentqueue/enqueue.go:23","msg":"Failed to validate event in queue .%!(EXTRA *errors.errorString=invalid routing key)","stacktrace":["github.com/PagerDuty/go-pdagent/pkg/persistentqueue.(*PersistentQueue).Enqueue\n\t/home/circleci/project/pkg/persistentqueue/enqueue.go:23\ngithub.com/PagerDuty/go-pdagent/pkg/server.(*Server).SendHandler\n\t/home/circleci/project/pkg/server/send_handler.go:24\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2041\ngithub.com/PagerDuty/go-pdagent/pkg/server.authMiddleware.func1.1\n\t/home/circleci/project/pkg/server/middleware.go:35\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2041\ngithub.com/PagerDuty/go-pdagent/pkg/server.loggingMiddleware.func1.1\n\t/home/circleci/project/pkg/server/middleware.go:13\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2041\ngithub.com/gorilla/mux.(*Router).ServeHTTP\n\t/go/pkg/mod/github.com/gorilla/mux@v1.7.4/mux.go:210\nnet/http.serverHandler.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2836\nnet/http.(*conn).serve\n\t/usr/local/go/src/net/http/server.go:1924"](mailto:github.com/PagerDuty/go-pdagent/pkg/persistentqueue.(*PersistentQueue).Enqueue\n\t/home/circleci/project/pkg/persistentqueue/enqueue.go:23\ngithub.com/PagerDuty/go-pdagent/pkg/server.(*Server).SendHandler\n\t/home/circleci/project/pkg/server/send_handler.go:24\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2041\ngithub.com/PagerDuty/go-pdagent/pkg/server.authMiddleware.func1.1\n\t/home/circleci/project/pkg/server/middleware.go:35\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2041\ngithub.com/PagerDuty/go-pdagent/pkg/server.loggingMiddleware.func1.1\n\t/home/circleci/project/pkg/server/middleware.go:13\nnet/http.HandlerFunc.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2041\ngithub.com/gorilla/mux.(*Router).ServeHTTP\n\t/go/pkg/mod/github.com/gorilla/mux@v1.7.4/mux.go:210\nnet/http.serverHandler.ServeHTTP\n\t/usr/local/go/src/net/http/server.go:2836\nnet/http.(*conn).serve\n\t/usr/local/go/src/net/http/server.go:1924)}
Please assist if i am missing on something or any other dependencies or any other things i have to do…
Regards,
usman