Skip to content
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
14 changes: 14 additions & 0 deletions docs/source/ruletypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2031,6 +2031,20 @@ Optional:

``servicenow_proxy``: By default ElastAlert will not use a network proxy to send notifications to ServiceNow. Set this option using ``hostname:port`` if you need to use a proxy.

``caller_id``: Used to log the ticket under another name than user making request.

``impact``: Used to specify the impact of the incident created.

``urgency``: Used to specify the urgency of the incident created.

``u_originating_group``: The originating group the incident is for.

``u_division``: The Division the incident is specified for.

``contact_type``: The preferred contact method.

``opened_by``: Specifies the user that opened it.


Debug
~~~~~
Expand Down
31 changes: 13 additions & 18 deletions elastalert/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1778,22 +1778,18 @@ def get_info(self):
class ServiceNowAlerter(Alerter):
""" Creates a ServiceNow alert """
required_options = set([
'username',
'password',
'servicenow_rest_url',
'apikey',
'servicedeskplus_rest_url',
'short_description',
'comments',
'assignment_group',
'category',
'subcategory',
'cmdb_ci',
'caller_id'
'subcategory'
])

def __init__(self, rule):
super(ServiceNowAlerter, self).__init__(rule)
self.servicenow_rest_url = self.rule['servicenow_rest_url']
self.servicenow_proxy = self.rule.get('servicenow_proxy', None)
self.servicedeskplus_rest_url = self.rule['servicedeskplus_rest_url'] +"?zapikey="+ self.rule['apikey']

def alert(self, matches):
for match in matches:
Expand All @@ -1805,33 +1801,32 @@ def alert(self, matches):
"Content-Type": "application/json",
"Accept": "application/json;charset=utf-8"
}
proxies = {'https': self.servicenow_proxy} if self.servicenow_proxy else None
payload = {
"description": description,
"short_description": self.rule['short_description'],
"comments": self.rule['comments'],
"assignment_group": self.rule['assignment_group'],
"category": self.rule['category'],
"subcategory": self.rule['subcategory'],
"cmdb_ci": self.rule['cmdb_ci'],
"caller_id": self.rule["caller_id"]
"impact": self.rule["impact"],
"urgency": self.rule["urgency"],
"priority": self.rule["impact"],
"u_division": self.rule["u_division"]
}
try:
response = requests.post(
self.servicenow_rest_url,
auth=(self.rule['username'], self.rule['password']),
self.servicedeskplus_rest_url,
headers=headers,
data=json.dumps(payload, cls=DateTimeEncoder),
proxies=proxies
)
response.raise_for_status()
except RequestException as e:
raise EAException("Error posting to ServiceNow: %s" % e)
elastalert_logger.info("Alert sent to ServiceNow")
raise EAException("Error posting to ServiceDeskPlus: %s" % e)
elastalert_logger.info("Alert sent to ServiceDeskPlus")

def get_info(self):
return {'type': 'ServiceNow',
'self.servicenow_rest_url': self.servicenow_rest_url}
return {'type': 'ServiceDeskPlus',
'self.servicedeskplus_rest_url': self.rule['servicedeskplus_rest_url']}


class AlertaAlerter(Alerter):
Expand Down
2 changes: 1 addition & 1 deletion elastalert/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class RulesLoader(object):
'telegram': alerts.TelegramAlerter,
'googlechat': alerts.GoogleChatAlerter,
'gitter': alerts.GitterAlerter,
'servicenow': alerts.ServiceNowAlerter,
'servicedeskplus': alerts.ServiceNowAlerter,
'alerta': alerts.AlertaAlerter,
'post': alerts.HTTPPostAlerter,
'hivealerter': alerts.HiveAlerter
Expand Down
8 changes: 8 additions & 0 deletions elastalert/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,14 @@ properties:
properties:
field: {type: string, minLength: 1}

### ServiceNow
impact: {type: [string, integer]}
urgency: {type: [string, integer]}
u_originating_group: {type: string}
u_division: {type: string}
contact_type: {type: string}
opened_by: {type: string}

### PagerDuty
pagerduty_service_key: {type: string}
pagerduty_client_name: {type: string}
Expand Down