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

PagerDuty incident resolution support #131

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

ivachkov
Copy link

PagerDuty incidents are generated with messages like:

[BEACON] CRITICAL <Test Wildcard Alert> (stats.gauges.server2.data) failed. Current value: 1.0

"Back to normal" messages look like:

[BEACON] NORMAL <Test Wildcard Alert> (stats.gauges.server1.data) is back to normal.

From those, I figured that incident-unique information is the combination of alert name (<Test Wildcard Alert>) and metrics name ((stats.gauges.server1.data)). To avoid storing data on the file system, I decided to generate a hash out of those two. Using this hash value incidents can be triggered and resolved in a stateless way.

Following tests were performed:

  • Tested alerts with exact metric match ("query": "stats.gauges.test")
  • Tested wildcard metrics alerts ("query": "stats.gauges.*.data")

Copy link
Collaborator

@garrettheel garrettheel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing!

Can you help me understand what the original issue was that prompted you to do this? As far as I can tell, we're already using rule['raw'] as the incident_key which should allow for stateless resolution

event_type = 'resolve'

# Extract unique alert identifiers
alert_name = message[message.find("<")+1:message.find(">")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the context passed into the function for the alert name and metric name instead of pulling it out of the message?

h.update(alert_metric)

# Use hash as incident key to support resolution
incident_key = h.hexdigest()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any benefit to md5ing these? Why not just do "{alert_name:alert_metric}"?

# Use hash as incident key to support resolution
incident_key = h.hexdigest()

if level == 'critical':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if level in ['critical', 'warning']:

else:
event_type = 'trigger'
return
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you're changing this?

"event_type": event_type,
"description": message,
"details": message,
"incident_key": rule['raw'] if rule is not None else 'graphite connect error',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this logic has has been lost, can you re-add it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants