{"id":20504080,"url":"https://github.com/icinga/icinga2-notification-alertops","last_synced_at":"2025-03-05T20:45:53.210Z","repository":{"id":145047144,"uuid":"49942545","full_name":"Icinga/icinga2-notification-alertops","owner":"Icinga","description":"Send notifications to AlertOps","archived":false,"fork":false,"pushed_at":"2016-07-14T12:50:38.000Z","size":579,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-01-16T07:37:35.304Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Icinga.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-19T09:45:19.000Z","updated_at":"2017-01-16T15:46:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"ef27c3b7-aa99-42c5-9f04-62f3a1b495c9","html_url":"https://github.com/Icinga/icinga2-notification-alertops","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icinga%2Ficinga2-notification-alertops","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icinga%2Ficinga2-notification-alertops/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icinga%2Ficinga2-notification-alertops/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icinga%2Ficinga2-notification-alertops/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Icinga","download_url":"https://codeload.github.com/Icinga/icinga2-notification-alertops/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242100931,"owners_count":20071823,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T19:36:15.769Z","updated_at":"2025-03-05T20:45:53.183Z","avatar_url":"https://github.com/Icinga.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Icinga 2 AlertOps Integration\n\n[AlertOps](http://alertops.com/) is a collaborative incident\nmanagement solution that integrates multi-modal communication,\napplication monitoring, change management and SLAs (service-level\nagreements). This notification script uses the [AlertOps Generic REST\nAPI](http://help.alertops.com/default.aspx/MyWiki/Generic%20REST%20API.html)\nto send alerts reported by Icinga 2 to your AlertOps account. Based\non your ruleset incidents can be automatically opened and closed,\ndepending on whether Icinga reports a problem or a recovery.\n\n## Prerequisites\n\nThis script requires Icinga 2.0.0 or later.\n\n### Perl packages\n\nThese libraries are used by the notification command:\n\n* HTTP::Request::Common\n* LWP::UserAgent\n* JSON\n\nIf you're using Debian or Ubuntu, install the following packages:\n\n    # apt-get install -y libhttp-message-perl libwww-perl libjson-perl cpanminus\n\nIf you're running openSUSE, install the following packages:\n\n    # zypper install perl-App-cpanminus perl-JSON\n\nOn CentOS install the following packages plus dependencies:\n\n    # yum install perl-libwww-perl perl-App-cpanminus\n\nNext, check out this GitHub repository and change into the\n`icinga2-notification-alertops` directory:\n\n```\n   # cd ~\n   # git clone https://github.com/Icinga/icinga2-notification-alertops.git\n   # cd icinga2-notification-alertops\n```\n\nThere is a `cpanminus` script (`cpanfile`) that contains a list of\nall Perl dependencies. Use the following command to check for missing\nCPAN modules and to install them in one go:\n\n    # cpanm --verbose --installdeps .\n\n![calling `cpanminus` on Debian Jessie](images/cpanminus-jessie.png \"calling `cpanminus` on Debian Jessie\")\n\n\u003e **Note**\n\u003e\n\u003e If you see an error message like `Can't locate Parse/PMFile.pm` on\n\u003e openSUSE Leap 42.1, you've probably run into [this\n\u003e bug](https://bugzilla.suse.com/show_bug.cgi?id=983472). One solution\n\u003e is to fetch the missing module from the [CPAN server](http://www.cpan.org/authors/id/I/IS/ISHIGAKI/Parse-PMFile-0.40.tar.gz),\n\u003e unpack the archive and copy the file `PMFile.pm` manually to `/usr/lib/perl5/5.18.2/Parse`.\n\u003e Next, run the `cpanm` command again.\n\n## Icinga 2 Configuration\n\nChange into the `/etc/icinga2/conf.d` directory and create a new\nconfiguration file, e.g. `alertops.conf`. Define a user object, a\nnotification command, two `Notification` objects (one for hosts and\none for services). (Alternatively, you can add the snippets to the\ncorresponding files on your Icinga 2 installation.)\n\n### User object\n\nThe user object defines where your notifications will be sent to.\nApart from the `display_name` (a short description of the user),\none or more groups (`groups`), a set of state and type filters that\nspecifies when the notification should be triggered (`states`,\n`types`), you need to configure your personal AlertOps API key. You\ncan find it in the AlertOps dashboard in the menu **Administration\n-\u003e Subscription Settings**.\n\n![Find your AlertOps API key.](images/api-key.png \"finding our AlertOps API key\")\n\n```\nobject User \"alertops\" {\n  display_name = \"AlertOps Notification User\"\n  groups = [ \"icingaadmins\" ]\n  states = [ OK, Warning, Critical, Unknown ]\n  types = [ Problem, Recovery ]\n\n  vars.alertops_apikey = \"a2ed82a783te7-4335-h378-0d2a5d1a7b64\"\n}\n```\n\nLearn more about user objects in the [Icinga 2 Docs](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/object-types#objecttype-user).\n\n### NotificationCommand\n\nThe notification command defines the location and parameters of\nthis script. The variables you enter here will be used in in the\nnotification rules later (see [Notification\nconfiguration](README.md#notifications-config)). This command\nexpects the notification script `alertops_notification.pl` in the\ndirectory `/etc/icinga2/scripts`:\n\n    # cp ~/icinga2-notification-alertops/alertops_notification.pl /etc/icinga2/scripts/\n\nThe configuration for the `NotificationCommand` can look like this:\n\n```\nobject NotificationCommand \"alertops-notification\" {\n  import \"plugin-notification-command\"\n  command = [ SysconfDir + \"/icinga2/scripts/alertops_notification.pl\" ]\n\n  env = {\n    \"ALERTOPS_APIKEY\" = \"$user.vars.alertops_apikey$\"\n  }\n\n  arguments = {\n          \"--source\"      = \"$alertops_source$\",\n          \"--source_name\" = \"$alertops_source_name$\",\n          \"--subject\"     = \"$alertops_subject$\",\n          \"--status\"      = \"$alertops_state$\",\n          \"--incident\"    = \"$alertops_incident$\",\n          \"--severity\"    = \"$alertops_severity$\",\n          \"--url\"         = \"$alertops_url$\",\n          \"--short_text\"  = \"$alertops_short_text$\",\n          \"--long_text\"   = \"$alertops_long_text$\",\n          \"--assignee\"    = \"$alertops_assignee$\"\n  }\n}\n```\n\nLearn more about the NotificationCommand object in the [Icinga 2 Docs](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/object-types#objecttype-notificationcommand).\n\n### \u003ca id=\"notifications-config\"\u003e\u003c/a\u003e Notifications\n\nNext, create the two `Notification` objects, one for hosts and one for\nservices. Define the command that sends out the notifications, the\n`User` object that you have created before (e.g. `alertops`), the\ntime period, and the states. For `Host` objects the state can be `Up` or\n`Down`, services can have the states `OK`, `Warning`, `Critical`,\nand `Unknown`. Additionally, enter one or more types, i.e. `Problem`,\n`Acknowledgement`, or `Recovery`.\n\n#### Hosts\n\n```\napply Notification \"alertops-host\" to Host {\n  command = \"alertops-notification\"\n  users = [ \"alertops\" ]\n  period = \"24x7\"\n  states = [ Up, Down ]\n  types = [ Problem, Acknowledgement, Recovery ]\n\n  vars.alertops_source = \"Icinga2\"\n  vars.alertops_source_name = \"Icinga2-Host\"\n  vars.alertops_subject = \"$host.name$ - $host.state$\"\n  vars.alertops_incident = \"$host.name$\"\n  vars.alertops_long_text = \"Host $host.name$ is $host.state$!\"\n  vars.alertops_state = \"$host.state$\"\n\n  assign where host.vars.notify_alertops == true\n}\n```\n\n#### Services\n\n```\napply Notification \"alertops-service\" to Service {\n  command = \"alertops-notification\"\n  users = [ \"alertops\" ]\n  period = \"24x7\"\n  states = [ OK, Warning, Critical, Unknown ]\n  types = [ Problem, Acknowledgement, Recovery ]\n\n  vars.alertops_source = \"Icinga2\"\n  vars.alertops_source_name = \"Icinga2-Service\"\n  vars.alertops_subject = \"$host.name$ - $service.name$ - $service.state$\"\n  vars.alertops_incident = \"$host.name$ - $service.name$\"\n  vars.alertops_long_text = \"Service $service.name$ on host $host.name$ is $service.state$!\"\n  vars.alertops_state = \"$service.state$\"\n\n  assign where service.vars.notify_alertops == true\n}\n```\n\n#### Variable for hosts/services\n\nIn order to enable a host or service to communicate with AlertOps and\nsend the alerts, add the previously configured custom variable:\n\n```\nvars.notify_alertops = true\n```\n\n### Restart Icinga 2\n\nAfter saving the configuration file and adding the custom variable\n`vars.notify_alertops` to a host or service object, please restart\nIcinga 2:\n\n    # systemctl restart icinga2\n\n## \u003ca id=\"alert-ops-config\"\u003e\u003c/a\u003e AlertOps Configuration\n\nAlertOps expects you to write rulesets to identify your alerts and\ncreate incidents based on multiple parameters. To do so, open the\nmenu **Administration -\u003e Inbound Integrations**. Since host and\nservices have different states, you need to define distinctive\nrules. Here are two different examples, one for hosts and one for\nservices:\n\n### Icinga Host Alerts\n\n| Option                  | Value           | \n| :---------------------- | :-------------- |\n| Integration Name        | Icinga2 Hosts   |\n| Source                  | Icinga2         |\n| Source-Name             | Icinga2-Host    |\n| Status Field            | SourceStatus    |\n| Open Alert on Value     | DOWN            |\n| Close Alert on Value    | UP              | \n\n### Icinga Service Alerts\n\n| Option                  | Value              | \n| :---------------------- | :-------------- |\n| Integration Name        | Icinga2 Services   |\n| Source                  | Icinga2            |\n| Source-Name             | Icinga2-Service    |\n| Status Field            | SourceStatus       |\n| Open Alert on Value     | CRITICAL           |\n| Close Alert on Value    | OK                 | \n\n*See the screenshots for some real use case impressions.* For more\ninformation on the AlertOps web interface, please refer to the [AlertOps\ndocumentation](http://alertops.com/documentation).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficinga%2Ficinga2-notification-alertops","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficinga%2Ficinga2-notification-alertops","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficinga%2Ficinga2-notification-alertops/lists"}