how to send alerts to different

Hi

we are using Sensu with EC2 instances with full success. But lately we have added more servers from other infrastructure and this servers depends not completely of us. So we have to send different alerts to different people, what problem do we have now? Duplicate checks. For example, a normal check will be:

{
“checks”: {
“check_httpd”: {
“command”: “/etc/sensu/plugins/check-procs.rb -p httpd -C 1”,
“interval”: 120,
“subscribers”: [“httpd”],
“handlers”: [“severity2”],
“occurrences”: 4
}
}
}

``

right? this is fine to our pool of webservers. But the new infrastructure also have webservers with Apache and I have to change the “handlers” to be able to send alerts with mail, hipchat, etc to other guys.

So only way I have found is duplicate the code

{
“checks”: {
“check_httpd_new_guys”: {
“command”: “/etc/sensu/plugins/check-procs.rb -p httpd -C 1”,
“interval”: 120,
“subscribers”: [“httpd_new_guys”],
“handlers”: [“severity2-new-guys”],
“occurrences”: 4
}
}
}

``

I’m full aware this is not the best approach. Do you have any idea of how manage this without have to duplicate the checks?

Thanks!

One method we use is to include additional metadata into the sensu-client config itself. Just regular JSON such as “environment”: “nonprod”, “send_emails”: true, “additional_emails”: “bob@example.com” etc. Then, we modified our handlers to make decisions based on what the client config contains. That way we can use a single check definition but have handlers behave differently based on the client that’s causing events.

···

On Monday, November 7, 2016 at 5:36:21 AM UTC-6, Rubén Ortiz wrote:

Hi

we are using Sensu with EC2 instances with full success. But lately we have added more servers from other infrastructure and this servers depends not completely of us. So we have to send different alerts to different people, what problem do we have now? Duplicate checks. For example, a normal check will be:

{
“checks”: {
“check_httpd”: {
“command”: “/etc/sensu/plugins/check-procs.rb -p httpd -C 1”,
“interval”: 120,
“subscribers”: [“httpd”],
“handlers”: [“severity2”],
“occurrences”: 4
}
}
}

``

right? this is fine to our pool of webservers. But the new infrastructure also have webservers with Apache and I have to change the “handlers” to be able to send alerts with mail, hipchat, etc to other guys.

So only way I have found is duplicate the code

{
“checks”: {
“check_httpd_new_guys”: {
“command”: “/etc/sensu/plugins/check-procs.rb -p httpd -C 1”,
“interval”: 120,
“subscribers”: [“httpd_new_guys”],
“handlers”: [“severity2-new-guys”],
“occurrences”: 4
}
}
}

``

I’m full aware this is not the best approach. Do you have any idea of how manage this without have to duplicate the checks?

Thanks!

Thanks to share your knowleadge! I will give it a try!

···

On Monday, November 7, 2016 at 12:46:55 PM UTC+1, uberamd wrote:

One method we use is to include additional metadata into the sensu-client config itself. Just regular JSON such as “environment”: “nonprod”, “send_emails”: true, “additional_emails”: “b...@example.com” etc. Then, we modified our handlers to make decisions based on what the client config contains. That way we can use a single check definition but have handlers behave differently based on the client that’s causing events.

On Monday, November 7, 2016 at 5:36:21 AM UTC-6, Rubén Ortiz wrote:

Hi

we are using Sensu with EC2 instances with full success. But lately we have added more servers from other infrastructure and this servers depends not completely of us. So we have to send different alerts to different people, what problem do we have now? Duplicate checks. For example, a normal check will be:

{
“checks”: {
“check_httpd”: {
“command”: “/etc/sensu/plugins/check-procs.rb -p httpd -C 1”,
“interval”: 120,
“subscribers”: [“httpd”],
“handlers”: [“severity2”],
“occurrences”: 4
}
}
}

``

right? this is fine to our pool of webservers. But the new infrastructure also have webservers with Apache and I have to change the “handlers” to be able to send alerts with mail, hipchat, etc to other guys.

So only way I have found is duplicate the code

{
“checks”: {
“check_httpd_new_guys”: {
“command”: “/etc/sensu/plugins/check-procs.rb -p httpd -C 1”,
“interval”: 120,
“subscribers”: [“httpd_new_guys”],
“handlers”: [“severity2-new-guys”],
“occurrences”: 4
}
}
}

``

I’m full aware this is not the best approach. Do you have any idea of how manage this without have to duplicate the checks?

Thanks!

Hi uberamd

would be so kind to post some example of the logic of one of your handler?

···

On Monday, November 7, 2016 at 12:46:55 PM UTC+1, uberamd wrote:

One method we use is to include additional metadata into the sensu-client config itself. Just regular JSON such as “environment”: “nonprod”, “send_emails”: true, “additional_emails”: “b...@example.com” etc. Then, we modified our handlers to make decisions based on what the client config contains. That way we can use a single check definition but have handlers behave differently based on the client that’s causing events.

On Monday, November 7, 2016 at 5:36:21 AM UTC-6, Rubén Ortiz wrote:

Hi

we are using Sensu with EC2 instances with full success. But lately we have added more servers from other infrastructure and this servers depends not completely of us. So we have to send different alerts to different people, what problem do we have now? Duplicate checks. For example, a normal check will be:

{
“checks”: {
“check_httpd”: {
“command”: “/etc/sensu/plugins/check-procs.rb -p httpd -C 1”,
“interval”: 120,
“subscribers”: [“httpd”],
“handlers”: [“severity2”],
“occurrences”: 4
}
}
}

``

right? this is fine to our pool of webservers. But the new infrastructure also have webservers with Apache and I have to change the “handlers” to be able to send alerts with mail, hipchat, etc to other guys.

So only way I have found is duplicate the code

{
“checks”: {
“check_httpd_new_guys”: {
“command”: “/etc/sensu/plugins/check-procs.rb -p httpd -C 1”,
“interval”: 120,
“subscribers”: [“httpd_new_guys”],
“handlers”: [“severity2-new-guys”],
“occurrences”: 4
}
}
}

``

I’m full aware this is not the best approach. Do you have any idea of how manage this without have to duplicate the checks?

Thanks!

mmm, still does not work. Does anyone have experience with this scenario?

···

On Monday, 7 November 2016 12:36:21 UTC+1, Rubén Ortiz wrote:

Hi

we are using Sensu with EC2 instances with full success. But lately we have added more servers from other infrastructure and this servers depends not completely of us. So we have to send different alerts to different people, what problem do we have now? Duplicate checks. For example, a normal check will be:

{
“checks”: {
“check_httpd”: {
“command”: “/etc/sensu/plugins/check-procs.rb -p httpd -C 1”,
“interval”: 120,
“subscribers”: [“httpd”],
“handlers”: [“severity2”],
“occurrences”: 4
}
}
}

``

right? this is fine to our pool of webservers. But the new infrastructure also have webservers with Apache and I have to change the “handlers” to be able to send alerts with mail, hipchat, etc to other guys.

So only way I have found is duplicate the code

{
“checks”: {
“check_httpd_new_guys”: {
“command”: “/etc/sensu/plugins/check-procs.rb -p httpd -C 1”,
“interval”: 120,
“subscribers”: [“httpd_new_guys”],
“handlers”: [“severity2-new-guys”],
“occurrences”: 4
}
}
}

``

I’m full aware this is not the best approach. Do you have any idea of how manage this without have to duplicate the checks?

Thanks!