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

Unable to define Contact Routing for Sensu Enterprise #597

Closed
stevenviola opened this issue Dec 28, 2016 · 5 comments
Closed

Unable to define Contact Routing for Sensu Enterprise #597

stevenviola opened this issue Dec 28, 2016 · 5 comments
Assignees

Comments

@stevenviola
Copy link

Description of problem

Per the Sensu Enterprise documentation, contacts need to be defined within the "contacts": {} configuration scope. An example of the way the contacts config should be defined is below:

{
  "contacts": {
    "support": {
      "email": {
        "to": "[email protected]"
      },
      "slack": {
        "channel": "#support"
      }
    }
  }
}

Using this puppet module, I don't see a way to define a contacts hash at the top level configuration scope. I tried tricking the module and used sensu::config to specify the contact hash, but I was unable to get this to work, when specifying the hash as the event or the config. Even if this did work, it was not an ideal solution, as I would need to masquerade the config as additional check configuration, and not as a contacts file.

I was finally able to find a solution by adding a handler using sensu::handler named contacts, and providing the contacts as a hash to the handler config. I needed to provide a dummy command to this handler, but since I am not going to be using it, I guess it's not a big deal. This added the "contacts": {} configuration scope and seems to be working, although it feels a bit hacky.

Is there any way to specify arbitrary configuration at the top level? Is there any need to add a contacts resource? How are others implementing the contact configuration with this puppet module?

Platform and version information

  • Your OS: CentOS 6
  • Your Ruby version: 2.3.0
  • Your version of Puppet: 4.8.1
  • Your version of Sensu: 0.26.5
  • Your version of this module: 2.2.0
@jaxxstorm
Copy link
Contributor

Yes this isn't possible currently, we'd need a PR to get this working.

You could possibly fudge it using custom

@stevenviola
Copy link
Author

Yes this isn't possible currently, we'd need a PR to get this working.

I didn't see much need from other having arbitrary JSON in the top level scope, other than what was talked about in #157, but that seems to have been resolved by adding the extension type. Is it safe to assume that it'll be best to add a contact type to handle this use case?

You could possibly fudge it using custom

Which custom could you use? Taking a look at client_custom and custom in the check definition, that puts the hash under the client and check scope respectively. If there's a better way to fudge it than making a dummy handler, than I can give that a try.

@agoddard
Copy link

Using arbitrary hashes w/ #661 and client_custom on the client, or custom check should support this

@jeffmccune jeffmccune self-assigned this Jul 9, 2017
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jul 10, 2017
Left off adding spec tests to the defined type, modeled off the handler defined
type.

Resolves sensu#597
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jul 11, 2017
Left off adding spec tests to the defined type, modeled off the handler defined
type.

Resolves sensu#597
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jul 11, 2017
Without this patch the Puppet module doesn't provide an affordance for [contact
routing](https://sensuapp.org/docs/0.29/enterprise/contact-routing.html)  This
patch addresses the problem by adding a new defined type, sensu::contact backed
by a custom type and provider for sensu_contact.

Example usage:

    sensu::contact { 'support':
      config => { 'email'  => { 'to' => '[email protected]' } },
    }
    sensu::contact { 'ops':
      config => { 'email'  => { 'to' => '[email protected]' } },
    }
    sensu::check { 'check_ntp':
      command     => 'PATH=$PATH:/usr/lib64/nagios/plugins check_ntp_time -H pool.ntp.org -w 30 -c 60',
      handlers    => 'email',
      contacts    => ['ops', 'support'],
    }

Resolves sensu#597
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jul 11, 2017
Without this patch the Puppet module doesn't provide an affordance for [contact
routing](https://sensuapp.org/docs/0.29/enterprise/contact-routing.html)  This
patch addresses the problem by adding a new defined type, sensu::contact backed
by a custom type and provider for sensu_contact.

Example usage:

    sensu::contact { 'support':
      config => { 'email'  => { 'to' => '[email protected]' } },
    }
    sensu::contact { 'ops':
      config => { 'email'  => { 'to' => '[email protected]' } },
    }
    sensu::check { 'check_ntp':
      command     => 'PATH=$PATH:/usr/lib64/nagios/plugins check_ntp_time -H pool.ntp.org -w 30 -c 60',
      handlers    => 'email',
      contacts    => ['ops', 'support'],
    }

Resolves sensu#597
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jul 11, 2017
Without this patch the Puppet module doesn't provide an affordance for [contact
routing](https://sensuapp.org/docs/0.29/enterprise/contact-routing.html)  This
patch addresses the problem by adding a new defined type, sensu::contact backed
by a custom type and provider for sensu_contact.

Example usage:

    sensu::contact { 'support':
      config => { 'email'  => { 'to' => '[email protected]' } },
    }
    sensu::contact { 'ops':
      config => { 'email'  => { 'to' => '[email protected]' } },
    }
    sensu::check { 'check_ntp':
      command     => 'PATH=$PATH:/usr/lib64/nagios/plugins check_ntp_time -H pool.ntp.org -w 30 -c 60',
      handlers    => 'email',
      contacts    => ['ops', 'support'],
    }

Resolves sensu#597
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jul 11, 2017
Without this patch the Puppet module doesn't provide an affordance for [contact
routing](https://sensuapp.org/docs/0.29/enterprise/contact-routing.html)  This
patch addresses the problem by adding a new defined type, sensu::contact backed
by a custom type and provider for sensu_contact.

Example usage:

    sensu::contact { 'support':
      config => { 'email'  => { 'to' => '[email protected]' } },
    }
    sensu::contact { 'ops':
      config => { 'email'  => { 'to' => '[email protected]' } },
    }
    sensu::check { 'check_ntp':
      command     => 'PATH=$PATH:/usr/lib64/nagios/plugins check_ntp_time -H pool.ntp.org -w 30 -c 60',
      handlers    => 'email',
      contacts    => ['ops', 'support'],
    }

Resolves sensu#597
jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jul 11, 2017
Without this patch the Puppet module doesn't provide an affordance for [contact
routing](https://sensuapp.org/docs/0.29/enterprise/contact-routing.html)  This
patch addresses the problem by adding a new defined type, sensu::contact backed
by a custom type and provider for sensu_contact.

Example usage:

    sensu::contact { 'support':
      config => { 'email'  => { 'to' => '[email protected]' } },
    }
    sensu::contact { 'ops':
      config => { 'email'  => { 'to' => '[email protected]' } },
    }
    sensu::check { 'check_ntp':
      command     => 'PATH=$PATH:/usr/lib64/nagios/plugins check_ntp_time -H pool.ntp.org -w 30 -c 60',
      handlers    => 'email',
      contacts    => ['ops', 'support'],
    }

Resolves sensu#597
@jeffmccune
Copy link
Collaborator

@stevenviola We've implemented this in #728 and should have it merged / released soon. Please let us know if you have any questions or comments about the implementation of the sensu::contact resource. Thanks for letting us know your need for this enhancement!

jeffmccune added a commit to jeffmccune/sensu-puppet that referenced this issue Jul 11, 2017
Without this patch the Puppet module doesn't provide an affordance for [contact
routing](https://sensuapp.org/docs/0.29/enterprise/contact-routing.html)  This
patch addresses the problem by adding a new defined type, sensu::contact backed
by a custom type and provider for sensu_contact.

Example usage:

    sensu::contact { 'support':
      config => { 'email'  => { 'to' => '[email protected]' } },
    }
    sensu::contact { 'ops':
      config => { 'email'  => { 'to' => '[email protected]' } },
    }
    sensu::check { 'check_ntp':
      command     => 'PATH=$PATH:/usr/lib64/nagios/plugins check_ntp_time -H pool.ntp.org -w 30 -c 60',
      handlers    => 'email',
      contacts    => ['ops', 'support'],
    }

Resolves sensu#597
ghoneycutt added a commit that referenced this issue Jul 11, 2017
(#597) Add sensu::contact type (Enterprise Only)
@ghoneycutt
Copy link
Collaborator

Fixed in release v2.20.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants