Skip to content

Commit

Permalink
Post incident update when issue is resolved
Browse files Browse the repository at this point in the history
This provides better feedback as it includes the resolution time
in the incident history.
  • Loading branch information
nijel committed Apr 30, 2020
1 parent eab52c8 commit 5bb3274
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions cachet_url_monitor/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,10 @@ def push_incident(self, status_value: status.ComponentStatus, is_public_incident
or updates the existing incident once it becomes healthy again.
"""
if previous_incident_id and status_value == status.ComponentStatus.OPERATIONAL:
# If the incident already exists, it means it was unhealthy but now it's healthy again.
params = {'status': status.IncidentStatus.FIXED.value, 'visible': is_public_incident,
'component_id': component_id, 'component_status': status_value.value, 'notify': True}
# If the incident already exists, it means it was unhealthy but now it's healthy again, post update
params = {'status': status.IncidentStatus.FIXED.value, 'message': title}

return requests.put(f'{self.url}/incidents/{previous_incident_id}', params=params, headers=self.headers)
return requests.post(f'{self.url}/incidents/{previous_incident_id}/updates', params=params, headers=self.headers)
elif not previous_incident_id and status_value != status.ComponentStatus.OPERATIONAL:
# This is the first time the incident is being created.
params = {'name': title, 'message': message,
Expand Down

0 comments on commit 5bb3274

Please sign in to comment.