ICinga+JIRA

Hi Team,

I am doing the icinga2 with JIRA integration to create the automated JIRA issue if any host or service having an issue.
below configuration i did after installation of module.

manually using icingacli as well as icinga GUI i am able to create the JIRA issue.
so when i am doing valication of icinga2 daemon -C i am getting an warning.

2021-07-16 20:00:46 +0200] warning/ApplyRule: Apply rule ‘jira-icingaadmin-host’ (in /etc/icinga2/conf.d/notifications.conf: 11:1-11:50) for type ‘Notification’ does not match anywhere!
[2021-07-16 20:00:46 +0200] warning/ApplyRule: Apply rule ‘jira-icingaadmin-service’ (in /etc/icinga2/conf.d/notifications.conf: 16:1-16:56) for type ‘Notification’ does not match anywhere!

so can you please help me how i can apply these service and host to my host or services example check_disk or ping
so that automtically JIRA issue will get created.

hosts.conf:
object Host “jira.com” {
import “generic-host”
address = “10.10.25.5”
check_command = “hostalive”
vars.agent = “ssh”
vars.mountpoint = “/app”
vars.user = “icinga”
vars.notification[“mail”] = { groups = [ “icingaadmins” ] }

services.conf

apply Service “jenkins-mountpoint[jira.com]” {
import “generic-service”
check_command = “mountxx”
vars.notification[“mail”] = { groups = [ “icingaadmins” ] }
assign where host.name == “jira.com
}

notification.conf
apply Notification “jira-icingaadmin-host” to Host {
import “jira-host-notification”
assign where host.vars.notification.jira == true
}

apply Notification “jira-icingaadmin-service” to Service {
import “jira-service-notification”
assign where service.vars.notification.jira == true
}

template.conf
template Notification “jira-host-notification” {
command = “jira-host-notification”
states = [ Up, Down ]
types = [ Problem, Acknowledgement, Recovery, Custom,
FlappingStart, FlappingEnd,
DowntimeStart, DowntimeEnd, DowntimeRemoved ]

vars += {
notification_logtosyslog = false
}
period = “24x7”
}
template Notification “jira-service-notification” {
command = “jira-service-notification”
states = [ OK, Warning, Critical, Unknown ]
types = [ Problem, Acknowledgement, Recovery, Custom,
FlappingStart, FlappingEnd,
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
vars += {
notification_logtosyslog = false
}

period = “24x7”
}

command.conf
object NotificationCommand “jira-host-notification” {
import “plugin-notification-command”
command = [ “/usr/bin/icingacli”, “jira”, “send”, “problem” ]
arguments += {
“–description” = {
description = “JIRA issue description”
required = true
value = “$jira_description$”
}
“–host” = “$host.name$”
“–issuetype” = {
description = “JIRA issue type (e.g. Incident)”
required = true
value = “$jira_issuetype$”
}
“–no-acknowledge” = {
description = “D not acknowledge Icinga problems once a JIRA issue got created”
value = “$jira_no_acknowledge$”
}
“–project” = {
description = “JIRA project name (e.g. ITSM)”
required = true
value = “$jira_project$”
}
“–state” = {
description = “Host state (e.g. DOWN)”
value = “$host.state$”
}
“–summary” = {
description = “JIRA issue summary”
required = true
value = “$jira_summary$”
}
“–template” = {
description = “Issue template name (templates.ini section). This allows to pass custom fields to JIRA”
value = “$jira_template$”
}
}
vars.jira_description = “$host.output$”
vars.jira_summary = “$host.name$ is $host.state$”
}
object NotificationCommand “jira-service-notification” {
import “plugin-notification-command”
command = [ “/usr/bin/icingacli”, “jira”, “send”, “problem” ]
arguments += {
“–description” = {
description = “JIRA issue description”
required = true
value = “$jira_description$”
}
“–host” = “$host.name$”
“–issuetype” = {
description = “JIRA issue type (e.g. Incident)”
required = true
value = “$jira_issuetype$”
}
“–no-acknowledge” = {
description = “D not acknowledge Icinga problems once a JIRA issue got created”
value = “$jira_no_acknowledge$”
}
“–project” = {
description = “JIRA project name (e.g. ITSM)”
required = true
value = “$jira_project$”
}
“–service” = “$service.name$”
“–state” = {
description = “Service state (e.g. CRITICAL)”
value = “$service.state$”
}
“–summary” = {
description = “JIRA issue summary”
required = true
value = “$jira_summary$”
}
“–template” = {
description = “Issue template name (templates.ini section). This allows to pass custom fields to JIRA”
value = “$jira_template$”
}
}
vars.jira_description = “$service.output$”
vars.jira_summary = “$service.name$ on $host.name$ is $service.state$”
}

@ log1c : can you please check and help the same, if i am missing anything

@ Feu Mourek[theFeu] : Can you please help the same

Hi @gaurav8591

I know you really need help, but it’'s not necessary to ping the community users explicitly all the time. I mean, if they had the time, you would have received your answer already. Anyway, please edit your first post for readability. Create topics and master Markdown formatting

So now, to your problem, you get these warnings cause your notification Apply rules don’t match anywhere, i.e. you do assign where host.vars.notification.jira == true in the apply rules but you set host.vars.notification.jira neither in the Host nor Service object definition. So once you add the following line to your Host and Service definition, the warnings should disappear.

vars.notification["jira"] = true

Best

Hi Team,

I have added the below parameter but new error is comming.

[2021-07-17 06:17:38 +0200] critical/config: Error: Validation failed for object ‘jira.de.pri.o2.com!jira-icingaadmin-host’ of type ‘Notification’; Attribute ‘command’: Object ‘jira-host-notification’ of type ‘NotificationCommand’ does not exist.

Location: in /etc/icinga2/conf.d/templates.conf: 94:3-94:36

/etc/icinga2/conf.d/templates.conf(92):

/etc/icinga2/conf.d/templates.conf(93): template Notification “jira-host-notification” {

/etc/icinga2/conf.d/templates.conf(94): command = “jira-host-notification”

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/etc/icinga2/conf.d/templates.conf(95): states = [ Up, Down ]

/etc/icinga2/conf.d/templates.conf(96): types = [ Problem, Acknowledgement, Recovery, Custom,

[2021-07-17 06:17:38 +0200] critical/config: 1 error

[2021-07-17 06:17:38 +0200] critical/cli: Config validation failed. Re-run with ‘icinga2 daemon -C’ after fixing the config.

@yhabteab : Can you please check my comments and help the same.

When the command.conf file, in which this NotificationCommand is located, is included correctly, this error message should not appear. I just have noticed that you have already created this NotificationCommand. Please make sure that this file is also located under the /etc/icinga2/conf.d directory.

And while testing it on my end, I noticed that your Apply rules are not working properly. After copying and testing your configs, I got the following error messages. The notification Apply rules need users or user groups.

[2021-07-19 16:56:16 +0200] critical/config: Error: Validation failed for object 'jira.com!jira-icingaadmin-host' of type 'Notification': Validation failed: No users/user_groups specified.
Location: in ~/Workspace/icinga2/prefix/etc/icinga2/conf.d/hosts.conf: 82:1-82:50

I have modified them slightly as follows.

apply Notification “jira-icingaadmin-host” to Host {
    import “jira-host-notification”

    //users = [ "john", "doe" ]
    user_groups = host.vars.notification.mail.groups

    assign where host.vars.notification.jira == true
}

apply Notification “jira-icingaadmin-service” to Service {
    import “jira-service-notification”

    //users = [ "john", "doe" ]
    user_groups = host.vars.notification.mail.groups

    assign where service.vars.notification.jira == true
}