Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to provide opsgenie-alerta severity map (#1) #373

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion plugins/opsgenie/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ The `OPSGENIE_SEND_WARN` setting should be configured if you would like to send
informational and warning alerts onto OpsGenie.

```python
OPSGENIE_SEND_WARN = True # default=True
OPSGENIE_SEND_WARN = True # default=False
```

The `OPSGENIE_SEVERITY_MAP` and `OPSGENIE_DEFAULT_SEVERITY` settings should be configured
to map Alerta severity to OpsGenie's priority.

```python
OPSGENIE_SEVERITY_MAP = { "critical": "P1", "warning": "P2", "informational": "P5" } # this is also default
OPSGENIE_DEFAULT_SEVERITY = "P3" # default="P3"
```

**Example**
Expand Down
5 changes: 4 additions & 1 deletion plugins/opsgenie/alerta_opsgenie.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
OPSGENIE_TEAMS = os.environ.get('OPSGENIE_TEAMS', '') # comma separated list of teams
OPSGENIE_SEND_WARN = os.environ.get('OPSGENIE_SEND_WARN') or app.config.get('OPSGENIE_SEND_WARN', False)
SERVICE_KEY_MATCHERS = os.environ.get('SERVICE_KEY_MATCHERS') or app.config['SERVICE_KEY_MATCHERS']
OPSGENIE_SEVERITY_MAP = os.environ.get('OPSGENIE_SEVERITY_MAP') or app.config.get('OPSGENIE_SEVERITY_MAP', { "critical": "P1", "warning": "P2", "informational": "P5", })
OPSGENIE_DEFAULT_SEVERITY = os.environ.get('OPSGENIE_DEFAULT_SEVERITY') or app.config.get('OPSGENIE_DEFAULT_SEVERITY', "P3")
DASHBOARD_URL = os.environ.get('DASHBOARD_URL') or app.config.get('DASHBOARD_URL', '')
LOG.info('Initialized: %s key, %s matchers' % (OPSGENIE_SERVICE_KEY, SERVICE_KEY_MATCHERS))

Expand Down Expand Up @@ -105,7 +107,8 @@ def post_receive(self, alert):
"entity": alert.environment,
"responders" : self.get_opsgenie_teams(),
"tags": [alert.environment, alert.resource, alert.service[0], alert.event],
"details": details
"details": details,
"priority": OPSGENIE_SEVERITY_MAP.get(alert.severity, OPSGENIE_DEFAULT_SEVERITY)
}

LOG.debug('OpsGenie CREATE payload: %s' % payload)
Expand Down