Can I use a Ruby handler in Sensu Go?

#1
  1. What have you already tried? Please include links to gists and/or code blocks (if relatively small)

I’m using the sensu/sensu:master image with Docker. I’m trying to integrate Sensu Go with Google Chat. I’ve found this handler https://github.com/clevertoday/sensu-plugins-hangouts-chat but it is written in Ruby for the 1.x version of Sensu.

Can I use this handler (or any handler writen in Ruby) with Sensu Go? Can I install a Ruby runtime inside the sensu-backend container? Or should I rewrite this handler in Go or another languaje?

  1. Tell us about your setup, this should include OS, version of Sensu, version of Sensu components (redis, rabbitmq), plugin versions (if applicable), anything special about your setup such as an airgapped network or strict ACLs

Sensu go inside a Docker container using the sensu/sensu:master image.

  1. Is there a Github issue related to your issue?

No.

  1. Is there anything else that can help us effectively help you?

I’ve installed Ruby inside the sensu-backend container (apk add ruby) but when executing the handler I get this error:

/usr/local/bin # ./handler-hangouts-chat.rb 
Traceback (most recent call last):
        2: from ./handler-hangouts-chat.rb:10:in `<main>'
        1: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- sensu-handler (LoadError)
#2

@chgonzalez :wave: you can install a ruby runtime via https://docs.sensu.io/sensu-go/5.2/installation/plugins/ . Ideally, the handler would be rewritten in Go so that it could be packaged as an asset, which would eliminate the need for installing the Ruby runtime and having to deal with any sort of PATH screwiness.

#3

So I must install a ruby runtime inside the sensu-backend container?

It seems that sensu/sensu:latest is based on Alpine image. There isn’t an Alpine package in PackageCloud. Should I copy the instructions from https://github.com/sensu/sensu-ruby-runtime/blob/master/Dockerfile.alpine and add it to my custom sensu-backend Dockerfile?

#4

Yes, in order to run Ruby scripts, you’ll need a Ruby runtime within your container. You should be able to use the same Dockerfile.alpine you found without any problem!