Skip to content

notify/opsgenie: log error from OpsGenie API#1965

Merged
simonpasquier merged 1 commit intoprometheus:masterfrom
simonpasquier:log-opsgenie-error
Jul 23, 2019
Merged

notify/opsgenie: log error from OpsGenie API#1965
simonpasquier merged 1 commit intoprometheus:masterfrom
simonpasquier:log-opsgenie-error

Conversation

@simonpasquier
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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