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

adding source for sensu alert as parameter #1314

Merged
merged 1 commit into from
Apr 18, 2017

Conversation

henry-megarry
Copy link

@henry-megarry henry-megarry commented Apr 11, 2017

Required for all non-trivial PRs
  • Rebased/mergable
  • Tests pass
  • CHANGELOG.md updated
  • Sign CLA (if not already signed)

Copy link
Contributor

@nathanielc nathanielc left a comment

Choose a reason for hiding this comment

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

Just a a few changes requested below. Thanks for the PR!

@@ -7751,6 +7756,7 @@ stream
.message('message')
.details('details')
.crit(lambda: TRUE)
.sensu()
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this change doing? The alert should be sent to sensu via the topic handler, not explicitly in the TICKscript.

Copy link
Author

Choose a reason for hiding this comment

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

The sensu TestServer_AlertHandlers test was failing without that being set.
server_test.go:7784: sensu: unexpected sensu request: exp [{Name:id Source:Kapacitor Output:message Status:2}] got []
Is there something I can do to make it work without that?

Copy link
Contributor

@nathanielc nathanielc Apr 11, 2017

Choose a reason for hiding this comment

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

This bit of code here should be registering a sensu handler for the topic test. So it should get an alert event, this hasn't changed in your code so I am not sure why you would be getting that error. But it should definitely be passing without the .sensu() bit as it was before.

Copy link
Author

Choose a reason for hiding this comment

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

It looks like I am getting this error in services/sensu/sensutest/sensutest.go line 53

"accept tcp 127.0.0.1:48578: use of closed network connection"

Not sure what I changed that would cause this to happen. Any suggestions on how to fix the issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, nothing is jumping out at me either. Maybe later I'll pull down the branch and take a look.

Copy link
Author

Choose a reason for hiding this comment

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

some more digging found that the Sensu service Handler() method is being called however the Handle() method is not. It is called if the .sensu() is in the tick script. How does the topic handler know to use the sensu service?

return
}
sourceStr := buf.String()
buf.Reset()
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to reset the buffer here as it isn't being used later.

if err != nil {
return handler{}, err
}
h, err := s.SensuService.Handler(c, s.logger)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is where a topic handler calls into the SensuService for the sensu handler. And it looks correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

I found the bug it is super subtle, the above line should read

h, err = s.SensuService.Handler(c, s.logger)

this is because we want to assign to the var h Handler from the function scope not our local scope. I should redesign this so that isn't so easy to mess up, but for now it will fix your test.

Copy link
Author

Choose a reason for hiding this comment

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

sweet thanks for the help! will get this in right away!

Copy link
Contributor

@nathanielc nathanielc left a comment

Choose a reason for hiding this comment

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

Just one tiny fix I missed before and then this should be good to go!

@@ -7391,6 +7393,9 @@ func TestServer_AlertHandlers(t *testing.T) {
{
handler: client.TopicHandler{
Kind: "sensu",
Options: map[string]interface{}{
"Source": "Kapacitor",
Copy link
Contributor

Choose a reason for hiding this comment

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

The key should be lower case to follow convention.

@nathanielc
Copy link
Contributor

@henry-megarry-tr The changes look good. :)

Just a few house keeping items to finish up

  • Add an entry to the CHANGELOG, in the feature section of the unreleased section.
  • Rebase and squash your commits into a single commit.
  • Sign the CLA so I can merge the code.

Thanks for this great PR! 🎉

@nathanielc nathanielc merged commit ce759fd into influxdata:master Apr 18, 2017
nathanielc added a commit that referenced this pull request Apr 18, 2017
adding source for sensu alert as parameter
@nathanielc nathanielc mentioned this pull request Apr 18, 2017
5 tasks
@nathanielc
Copy link
Contributor

@henry-megarry-tr Thanks, merged.

Closed #1132

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