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

notify/opsgenie: log error from OpsGenie API #1965

Merged
merged 1 commit into from
Jul 23, 2019

Conversation

simonpasquier
Copy link
Member

Ref: https://groups.google.com/d/msg/prometheus-users/3sAQ9kxEgPI/rE-ADUYiBAAJ

Tested against OpsGenie API, the error message looks like this:

cancelling notify retry for \"opsgenie\" due to unrecoverable error: unexpected status code 422: {\"message\":\"Request body is not processable. Please check the errors.\",\"errors\":{\"priority\":\"should be one of [ P1, P2, P3, P4, P5 ]\"},\"took\":0.005,\"requestId\":\"610e618e-7138-4898-9c70-c4eef2d68bf8\"}

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Awesome, I think it makes sense, but I would suggest splitting this retry function (and maybe rename to isRetriable) to keep things clear. What to do you think?

Otherwise LGTM

}

return false, nil
err := errors.Errorf("unexpected status code %v", statusCode)
Copy link
Member

Choose a reason for hiding this comment

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

I think we put too many things into this function to just name it retry (:

Can we have isRetriable with what we have previously and then have this:

err := errors.Errorf("unexpected status code %v", statusCode)
if body != nil {
		if bs, errRead := ioutil.ReadAll(body); errRead == nil {
			err = errors.Errorf("%s: %s", err, string(bs))
		}
	}

in Notify if the isRetriable(..) is false?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, it wouldn't work as-is because we can have errors that shouldn't be retried and for which logging the response body is still useful IMO.

FWIW the current form is consistent with what we have in other places (eg Slack). If anything we should factor out what is common across notifiers.

Copy link
Contributor

@stuartnelson3 stuartnelson3 left a comment

Choose a reason for hiding this comment

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

looks good to me. maybe it would be good to look at the notifiers now that they're all nicely split out and see what we can simplify, but definitely for another issue/pr.

@simonpasquier simonpasquier merged commit bdd91d2 into prometheus:master Jul 23, 2019
@simonpasquier simonpasquier deleted the log-opsgenie-error branch July 23, 2019 07:49
@simonpasquier
Copy link
Member Author

I'll have a look for the next step.

DuskEagle pushed a commit to DuskEagle/alertmanager that referenced this pull request Aug 1, 2019
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
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.

3 participants