Skip to content

Commit

Permalink
Merge pull request #105 from opsgenie/OPSGENIE-1095
Browse files Browse the repository at this point in the history
OPSGENIE-1095 fix eventId parsing from alert response
  • Loading branch information
emelkomurcu authored Mar 8, 2024
2 parents 722f1a9 + 7de88f4 commit fc89d92
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
6 changes: 5 additions & 1 deletion Zabbix/scripts/actionExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def main():
"id": 1,
"method": "event.acknowledge",
"params": {
"eventids": queue_message["alert"]["details"]["eventId"],
"eventids": parse_from_details("eventId", alert_response),
"message": "Acknowledged by " + alert_response.json()['data']['report'][
'acknowledgedBy'] + " via Opsgenie"
}
Expand All @@ -134,6 +134,10 @@ def main():
else:
logging.warning("Alert id does not exist ")

def parse_from_details(key,alert_response):
if key in alert_response.json()['data']["details"].keys():
return alert_response.json()['data']["details"][key]
return ""

if __name__ == '__main__':
main()
11 changes: 9 additions & 2 deletions Zabbix/scripts/actionExecutorForZabbix4.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def login_to_zabbix(user, password, url):
return login_result.json()['result']
else:
logging.error(
LOG_PREFIX + " Cannot login to Zabbix: Response " + str(login_result.status_code) + " " + str(login_result.content))
LOG_PREFIX + " Cannot login to Zabbix: Response " + str(login_result.status_code) + " " + str(
login_result.content))


def main():
Expand Down Expand Up @@ -106,7 +107,7 @@ def main():
"id": 1,
"method": "event.acknowledge",
"params": {
"eventids": queue_message["alert"]["details"]["eventId"],
"eventids": parse_from_details("eventId", alert_response),
"message": "Acknowledged by " + alert_response.json()['data']['report'][
'acknowledgedBy'] + " via Opsgenie",
"action": 6
Expand Down Expand Up @@ -134,5 +135,11 @@ def main():
logging.warning("Alert id does not exist ")


def parse_from_details(key, alert_response):
if key in alert_response.json()['data']["details"].keys():
return alert_response.json()['data']["details"][key]
return ""


if __name__ == '__main__':
main()
6 changes: 5 additions & 1 deletion Zabbix/scripts/actionExecutorForZabbix6.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def main():
"id": 1,
"method": "event.acknowledge",
"params": {
"eventids": queue_message["alert"]["details"]["eventId"],
"eventids": parse_from_details("eventId", alert_response),
"message": "Acknowledged by " + alert_response.json()['data']['report'][
'acknowledgedBy'] + " via Opsgenie",
"action": 6
Expand All @@ -133,6 +133,10 @@ def main():
else:
logging.warning("Alert id does not exist ")

def parse_from_details(key,alert_response):
if key in alert_response.json()['data']["details"].keys():
return alert_response.json()['data']["details"][key]
return ""

if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion release/oec-builder/oecScriptsVersion.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"Splunk": "1.1.4",
"Trackit": "1.1.3",
"Xmpp": "1.1.3",
"Zabbix": "1.1.9",
"Zabbix": "1.1.10",
"Zendesk": "1.1.3",
"Zenoss": "1.1.3"
}

0 comments on commit fc89d92

Please sign in to comment.