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

Define sensu source in the sensu service #1132

Closed
ellis2323 opened this issue Jan 17, 2017 · 10 comments
Closed

Define sensu source in the sensu service #1132

ellis2323 opened this issue Jan 17, 2017 · 10 comments

Comments

@ellis2323
Copy link

ellis2323 commented Jan 17, 2017

Hello,

I'm using telegraf to monitor network equipments. I have many hundred of equipments. With kapacitor i'm checking the ping and push alerts on my sensu.
The problem is that you define the source in the kapacitor.conf:
services/sensu/service.go line 136 (method prepareData)

postData["source"] = c.Source

With this config, all the alerts goes into the same client. So i have one client with one alert per equipements.

To change this behavious (https://github.com/ellis2323/kapacitor/), i have a made a little patch. Not sure that the way to do :) I have added a Hostname in the event.State among the ID, message, details and i put it in the

postData["source"] = hostname

My alert in TICKS is like this:

stream
  |from()
       .measurement('ping')
  |alert()
        .id('{{ .Name }}.{{ index .Tags "url" }}')
        .hostname('{{ index .Tags "url" }}')
        .info(lambda: "average_response_ms" > 10)
        .warn(lambda: "average_response_ms" > 20)
        .crit(lambda: "average_response_ms" > 30)
        .sensu()

With this hack, i have one client alert by equipement. It is more readable
My new result

@nathanielc
Copy link
Contributor

@ellis2323 Thanks for creating the patch! See https://help.github.com/articles/creating-a-pull-request/ for how to submit a pull request against this repo and we can discuss getting it merged.

@ellis2323
Copy link
Author

Not really sure if it's the best solution. I think it could be easier not to use my hostname but use in "source" the ID. Or to put the source expr in sensu('{{ index .Tags "url" }}').

@henry-megarry
Copy link

This would be really helpful to have, when can we expect to see the PR?

@ellis2323
Copy link
Author

Hi @henry-megarry-tr,

What do you prefer ? Look the alerta config for a coherency. They have way more parameters

@henry-megarry
Copy link

@ellis2323

I would do it the same way that they set up the channel for slack. You can have it set in the config, but you can also change it per alert. I'm not very familiar with go but I think you can see how they do it in kapacitor/services/slack/service.go

@mega0022
Copy link

I have been trying to do it the same way that slack does it, however it wont replace the '{{ index .Tags "url" }}' part for some reason.

https://github.com/mega0022/kapacitor

@nathanielc
slack.channel doesn't seem to be able to do that either, is there a way I can get it to or is it impossible?

@ellis2323
The way you did it on your fork seems fine, I would go ahead and start the PR process. If there is a way to get the replacing to happen we can discuss which way would be better.

@ellis2323
Copy link
Author

So ? if you want a PR, i can create one tomorrow.

@mega0022
Copy link

That would be fantastic!

@ellis2323
Copy link
Author

ok i have synced my repo and created a PR #1214

@henry-megarry
Copy link

I have moved source into the sensu handler and made a pull request #1314

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

No branches or pull requests

4 participants