{"id":21470092,"url":"https://github.com/sensu-plugins/sensu-plugins-opsgenie","last_synced_at":"2025-08-04T12:07:45.114Z","repository":{"id":27375503,"uuid":"30851144","full_name":"sensu-plugins/sensu-plugins-opsgenie","owner":"sensu-plugins","description":"Sensu plugins for OpsGenie","archived":false,"fork":false,"pushed_at":"2022-03-29T01:05:11.000Z","size":100,"stargazers_count":4,"open_issues_count":18,"forks_count":24,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-07-11T21:38:01.605Z","etag":null,"topics":["sensu-handler","sensu-plugins"],"latest_commit_sha":null,"homepage":"http://sensu-plugins.io","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sensu-plugins.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-16T02:41:12.000Z","updated_at":"2023-12-18T21:12:10.000Z","dependencies_parsed_at":"2022-08-20T17:10:23.334Z","dependency_job_id":null,"html_url":"https://github.com/sensu-plugins/sensu-plugins-opsgenie","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/sensu-plugins/sensu-plugins-opsgenie","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sensu-plugins%2Fsensu-plugins-opsgenie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sensu-plugins%2Fsensu-plugins-opsgenie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sensu-plugins%2Fsensu-plugins-opsgenie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sensu-plugins%2Fsensu-plugins-opsgenie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sensu-plugins","download_url":"https://codeload.github.com/sensu-plugins/sensu-plugins-opsgenie/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sensu-plugins%2Fsensu-plugins-opsgenie/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268214021,"owners_count":24214352,"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","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["sensu-handler","sensu-plugins"],"created_at":"2024-11-23T09:22:49.971Z","updated_at":"2025-08-04T12:07:45.068Z","avatar_url":"https://github.com/sensu-plugins.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Sensu-Plugins-opsgenie\n\n[![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-opsgenie.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-opsgenie)\n[![Gem Version](https://badge.fury.io/rb/sensu-plugins-opsgenie.svg)](http://badge.fury.io/rb/sensu-plugins-opsgenie)\n[![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-opsgenie/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-opsgenie)\n[![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-opsgenie/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-opsgenie)\n[![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-opsgenie.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-opsgenie)\n\n## Functionality\n\n## Files\n * `bin/handler-opsgenie.rb`\n * `bin/check-opsgenie-heartbeat.rb`\n\n## Usage\n\n**`handler-opsgenie`**\n```json\n{\n  \"opsgenie\": {\n    \"customerKey\": \"the-key\",\n    \"teams\": [\n      { \"name\": \"the-team\" },\n      { \"id\": \"4513b7ea-3b91-438f-b7e4-e3e54af9147c\" }\n    ],\n    \"recipients\": \"the-recipients\",\n    \"source\": \"alert-source\",\n    \"overwrite_quiet_hours\": true,\n    \"tags\": [\"sensu\"]\n  }\n}\n```\n\n## Installation\n\n[Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)\n\n## Configuration\nTo get this to work you need to specify a few different things. For a list of fields that are required/available look at the [sensu documentation](https://sensuapp.org/docs/0.25/enterprise/integrations/opsgenie.html). These files need to be on the server and the client boxes. Once there restart sensu-server and sensu-api.\n\n  - declare this as a handler: `/etc/sensu/conf.d/handler_opsgenie.json`\n``` json\n{\n  \"handlers\": {\n    \"opsgenie\": {\n      \"type\": \"pipe\",\n      \"command\": \"/opt/sensu/embedded/bin/handler-opsgenie.rb\"\n    }\n  },\n  \"opsgenie\": {\n    \"customerKey\": \"YOUR-KEY-HERE\"\n  }\n}\n```\n\n  - add it to the check: `/etc/sensu/conf.d/check_xxx.json`\n``` json\n{\n  \"checks\": {\n    \"check_elastinats_is_running\": {\n      \"command\": \"/opt/sensu/embedded/bin/check-process.rb -p cron\",\n      \"interval\": 60,\n      \"handlers\": [ \"opsgenie\" ],\n      \"subscribers\": [ \"core\" ]\n    }\n  }\n}\n```\n\n  - optionally add it to the default handler: `/etc/sensu/conf.d/default_handler.json`\n``` json\n{\n  \"handlers\": {\n    \"default\": {\n      \"type\": \"set\",\n      \"handlers\": [\n        \"opsgenie\"\n      ]\n    }\n  }\n}\n```\n\n## OpsGenie Alerts\n\nHow does the handler map the various Sensu values into the OpsGenie\n[alerts and alert fields](https://docs.opsgenie.com/docs/alerts-and-alert-fields) created?\n\n### Message\n\nThe OpsGenie _message_ alert field is comprised of the Sensu client name, and\nthe Sensu check name, _e.g._:\n```\nweb01 : check_mysql_access\n```\n\n### Teams\n\nThe OpsGenie _team_ alert field uses the values in the Sensu check configuration\nif any, otherwise it uses the value from the handler configuration.\n\n### Recipients\n\nThe OpsGenie _recipients_ alert field uses the values in the Sensu check\nconfiguration if any, otherwise it uses the value from the handler\nconfiguration.\n\n### Alias\n\nThe OpsGenie _alias_ alert is field is comprised of the Sensu client name,\nand the Sensu check name to create a unique key, _e.g._:\n```\nweb01:check_mysql_access\n```\nNote that this can be changed via configuration; see notes below.\n\n### Entity\n\nThe OpsGenie _entity_ alert field uses the Sensu client name.\n\n### Description\n\nThe OpsGenie _description_ alert field is populated with the Sensu check output.\n\n### Priority\n\nThe OpsGenie _priority_ alert field is not explicitly set; OpsGenie will thus\nassign the default priority of \"P3\" to the alert.\n\n\n## Configuration Notes\n\n### Per Check Attributes\n\n#### `alias`\n\nIf the check definition uses the custom `alias` attribute, _e.g._:\n```\n{\n  \"checks\": {\n    \"check_mysql_access\": {\n      \"opsgenie\": {\n        \"alias\": \"MyCustomAlias\",\n\n```\nthen the `handler-opsgenie.rb` handler will use that attribute value as the\nOpsGenie event ID.  This can be useful for alert deduplication; checks on\ndifferent clients for the same downstream resource can specify the same\n`alias` attribute, so that multiple alerts for the same resource are\nde-duplicated.\n\nBy default, `handler-opsgenie.rb` creates an event ID from the client name\nand the check name.  Thus:\n```\n{\n  \"checks\": {\n    \"check_mysql_access\": {\n      \"command\": \"/opt/sensu/embedded/bin/check-database.rb -h mysqldb\",\n      \"interval\": 60,\n      \"handlers\": [ \"opsgenie\" ],\n      \"standalone\": true\n    }\n  }\n```\nrunning on a client named `web01` will create an alert using an event ID of\n`web01:check_mysql_access`.  And on a client named `web02`, it would create an\nalert with a _different_ event ID of `web02:check_mysql_access`, even though\nthe `mysqldb` server being checked is the same for these clients.\n\nWe can define a custom `alias` attribute in this check:\n```\n{\n  \"checks\": {\n    \"check_mysql_access\": {\n      \"command\": \"/opt/sensu/embedded/bin/check-database.rb -h mysqldb\",\n      \"interval\": 60,\n      \"handlers\": [ \"opsgenie\" ],\n      \"standalone\": true,\n\n      \"opsgenie\": {\n        \"alias\": \"mysqldb\"\n      }\n    }\n  }\n```\nAnd with this, running on multiple clients, any alerts would be generated\nwith the same event ID of `mysqldb`, by using that `alias` attribute as the\nevent ID.\n\n#### `priority`\n\nBy default, an OpsGenie alert is created with a default [priority](https://docs.opsgenie.com/docs/priority-settings) value of \"P3\".  The priority for a specific\ncheck can be explicitly set using the custom `priority` attribute, _e.g._:\n```\n{\n  \"checks\": {\n    \"check_mysql_access\": {\n      \"opsgenie\": {\n        \"priority\": \"P1\",\n\n```\nThe list of valid values, per [OpsGenie alert docs](https://docs.opsgenie.com/docs/alert-api#section-create-alert), are:\n\n* P1\n* P2\n* P3\n* P4\n* P5\n\nAny value other than these will be ignored.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsensu-plugins%2Fsensu-plugins-opsgenie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsensu-plugins%2Fsensu-plugins-opsgenie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsensu-plugins%2Fsensu-plugins-opsgenie/lists"}