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: log PagerDuty v1 response on BadRequest #1481

Merged
merged 1 commit into from
Jul 30, 2018

Conversation

adamdecaf
Copy link
Contributor

We had a problem (our fault) and PagerDuty was sending back 400's, but it was hard to debug without the error response from PagerDuty.

@adamdecaf adamdecaf force-pushed the pagerduty-log-retryV1-error branch from a693852 to e6e1519 Compare July 25, 2018 19:58
notify/impl.go Outdated
if statusCode/100 != 2 {
return (statusCode == 403 || statusCode/100 == 5), fmt.Errorf("unexpected status code %v", statusCode)
} else if statusCode == 400 && resp.Body != nil {
Copy link
Member

@simonpasquier simonpasquier Jul 26, 2018

Choose a reason for hiding this comment

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

This won't work since a 400 statusCode would satisfy the first test at L613.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops. Fixed.

@adamdecaf adamdecaf force-pushed the pagerduty-log-retryV1-error branch from e6e1519 to a5c01d7 Compare July 26, 2018 15:26
Copy link
Member

@mxinden mxinden 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 looking into this @adamdecaf.

More general question: Why only include the body in the error message if the code is 400? Why not include it in general? Would that be to noisy?

//CC @simonpasquier

notify/impl.go Outdated
if statusCode == 400 && resp.Body != nil {
bs, err := ioutil.ReadAll(resp.Body)
if err != nil {
return false, fmt.Errorf("unexpected status code %v | problem reading response: %v", statusCode, err)
Copy link
Member

Choose a reason for hiding this comment

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

We are using : instead of | to separate errors in the Alertmanager project.

notify/impl.go Outdated
if err != nil {
return false, fmt.Errorf("unexpected status code %v | problem reading response: %v", statusCode, err)
}
return false, fmt.Errorf("bad request: %v", string(bs))
Copy link
Member

Choose a reason for hiding this comment

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

Maybe still worth printing the status code here?

@adamdecaf
Copy link
Contributor Author

@mxinden There only looks to be a body on 400. There's no 429 on the v1 endpoint and 403 is blank.

https://v2.developer.pagerduty.com/v2/docs/trigger-events

It might be noisy, but right now there's no real way to see what's wrong from the PD side.

Signed-off-by: Adam Shannon <adamkshannon@gmail.com>
@adamdecaf adamdecaf force-pushed the pagerduty-log-retryV1-error branch from a5c01d7 to d117c95 Compare July 27, 2018 15:54
@mxinden
Copy link
Member

mxinden commented Jul 30, 2018

@adamdecaf sounds good to me. Printing the body is a good idea, and probably more signal than noise to most users.

@simonpasquier @stuartnelson3 any further thoughts, otherwise I will go ahead and merge.

@mxinden mxinden merged commit 7745289 into prometheus:master Jul 30, 2018
@mxinden
Copy link
Member

mxinden commented Jul 30, 2018

@adamdecaf thanks for the contribution!

@adamdecaf adamdecaf deleted the pagerduty-log-retryV1-error branch July 30, 2018 14:28
gabreal pushed a commit to paritytech/alertmanager that referenced this pull request Jul 31, 2018
Signed-off-by: Adam Shannon <adamkshannon@gmail.com>
mxinden pushed a commit to mxinden/alertmanager that referenced this pull request Aug 14, 2018
Signed-off-by: Adam Shannon <adamkshannon@gmail.com>
milesbxf added a commit to monzo/alertmanager that referenced this pull request Jan 24, 2020
Applies prometheus#1481 to the
Pagerduty V2 retry path
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.

4 participants