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

mutator-influxdb-line-protocol.rb #32

Closed
ssirobertreilly opened this issue Jun 20, 2017 · 23 comments
Closed

mutator-influxdb-line-protocol.rb #32

ssirobertreilly opened this issue Jun 20, 2017 · 23 comments

Comments

@ssirobertreilly
Copy link

ssirobertreilly commented Jun 20, 2017

when using the udp line protocol, this my handler

{
  "handlers": {
    "influxdb_udp": {
      "type": "udp",
      "socket": {
        "host": "localhost",
        "port": 8089
      },
      "mutator": "influxdb_line_protocol"
    }
  }
}

but file is named mutator-influxdb-line-protocol.rb,
in the log i get

{"timestamp":"2017-06-20T15:49:15.566043-0400","level":"error","message":"unknown handler","handler_name":"influxdb_udp"}

sensu 0.29
influxdb 1.2.4

@majormoses
Copy link
Member

Can you validate it is installed as an extension? extensions require a bit more setup than normal plugins: https://sensuapp.org/docs/0.29/reference/extensions.html#installing-sensu-extensions

@ssirobertreilly
Copy link
Author

ssirobertreilly commented Jul 5, 2017

ok so i found it is installed correctly because of the following error
https://pastebin.com/7QiUzJwe

@ssirobertreilly
Copy link
Author

ssirobertreilly commented Jul 5, 2017

gem env

RubyGems Environment:
  - RUBYGEMS VERSION: 2.6.10
  - RUBY VERSION: 2.4.1 (2017-03-22 patchlevel 111) [x86_64-linux]
  - INSTALLATION DIRECTORY: /opt/sensu/embedded/lib/ruby/gems/2.4.0
  - USER INSTALLATION DIRECTORY: /root/.gem/ruby/2.4.0
  - RUBY EXECUTABLE: /opt/sensu/embedded/bin/ruby
  - EXECUTABLE DIRECTORY: /opt/sensu/embedded/bin
  - SPEC CACHE DIRECTORY: /root/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /opt/sensu/embedded/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /opt/sensu/embedded/lib/ruby/gems/2.4.0
     - /root/.gem/ruby/2.4.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /root/bin

@majormoses
Copy link
Member

@ssirobertreilly ok thanks I will take a look in a bit when I have some time just to make sure can you validate /etc/sensu/extensions/mutator-influxdb-line-protocol.rb exists?

@ssirobertreilly
Copy link
Author

ssirobertreilly commented Jul 5, 2017

ls -al /etc/sensu/extensions/mutator-influxdb-line-protocol.rb
-rwxr-xr-x 1 root root 552 Jul 5 13:09 /etc/sensu/extensions/mutator-influxdb-line-protocol.rb

@ssirobertreilly
Copy link
Author

I changed the perms on it to rule that out still get long stack and this error
{"timestamp":"2017-07-05T14:27:23.333719-0400","level":"warn","message":"ignoring extension","file":"/etc/sensu/extensions/mutator-influxdb-line-protocol.rb"}

@ssirobertreilly
Copy link
Author

ssirobertreilly commented Jul 5, 2017

also, when i attempt to use the influxdb check i get the same message.

@ssirobertreilly
Copy link
Author

at this point it looks like it is missing the gem 'cause', yet it is installed
./gem list |grep -i cause
cause (0.1)

@majormoses
Copy link
Member

majormoses commented Jul 5, 2017

Can you verify in /etc/default/sensu that you are using the embedded ruby?

@ssirobertreilly
Copy link
Author

ssirobertreilly commented Jul 5, 2017

cat /etc/default/sensu
EMBEDDED_RUBY=true

@majormoses
Copy link
Member

Strange, I validated that that is an indirect dependency from influxdb gem and assuming the relative path you are giving me from sensu is what I expect this should work just fine. As a side note (not saying we cant fix or work around) I see this: InfluxCommunity/influxdb-ruby@6d8918a so maybe once they release we can bump the version and then this goes away?

@majormoses
Copy link
Member

Here is the running theory I have and need some validation on your end, what version are you testing?

Some things that seem related:
In 1.1.0 (should have been a major version) we removed ruby 1.9 support: eec7387.

Here is a full list of changes: 1.0.0...1.1.0.

If you are using prior to these issues makes sense to me why its broken: InfluxCommunity/influxdb-ruby#151 and InfluxCommunity/influxdb-ruby#148

@ssirobertreilly
Copy link
Author

sensu 0.29
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
influxdb-1.2.4-1.x86_64
gems
influxdb (0.3.13)
sensu-plugins-influxdb (1.2.0)

@eheydrick
Copy link
Contributor

In 1.1.0 (should have been a major version) we removed ruby 1.9 support: eec7387.

@majormoses That was in 1.0.0

@ssirobertreilly thanks for all the info. i'm going to try to repro your issue and see what's going on.

@majormoses
Copy link
Member

my bad, github UI confuses me again...I need to stop using the UI...

@eheydrick
Copy link
Contributor

Hey @ssirobertreilly, I got this working. Can you run through an installation and compare with the output I got. It looks like you're doing everything right but there could be something subtly different.

1. Install the plugin:

$ sudo /opt/sensu/embedded/bin/gem install sensu-plugins-influxdb -v 1.2.0 --no-rdoc --no-ri
Fetching: dentaku-2.0.9.gem (100%)
Successfully installed dentaku-2.0.9
Fetching: cause-0.1.gem (100%)
Successfully installed cause-0.1
Fetching: influxdb-0.3.13.gem (100%)
Successfully installed influxdb-0.3.13
Fetching: multi_json-1.12.1.gem (100%)
Successfully installed multi_json-1.12.1
Fetching: jsonpath-0.5.8.gem (100%)
Successfully installed jsonpath-0.5.8
Fetching: sensu-plugins-influxdb-1.2.0.gem (100%)
You can use the embedded Ruby by setting EMBEDDED_RUBY=true in /etc/default/sensu
Successfully installed sensu-plugins-influxdb-1.2.0
6 gems installed

2. Verify the influxdb gem loads

$ /opt/sensu/embedded/bin/irb
/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/rb-readline-0.5.3/lib/rbreadline.rb:13: warning: constant ::Fixnum is deprecated
irb(main):001:0> require 'influxdb'
=> true

3. Link the extension in the extensions dir

$ ln -s /opt/sensu/embedded/bin/mutator-influxdb-line-protocol.rb /etc/sensu/extensions/mutator-influxdb-line-protocol.rb

4. Create the handler configuration. /etc/sensu/conf.d/handlers/influxdb_udp.json:

{
  "handlers": {
    "influxdb_udp": {
      "type": "udp",
      "mutator": "influxdb_line_protocol",
      "socket": {
        "host": "influxdb.my.site",
        "port": 8089
      }
    }
  }
}

5. Configure metrics checks to use the influxdb_udp handler

6. Restart sensu-server

There was also a bit of setup on the influxdb end for UDP - https://github.com/influxdata/influxdb/blob/master/services/udp/README.md

@ssirobertreilly
Copy link
Author

@eheydrick I will remove and re run through the setup, I did do the prework of enabling udp for influxdb.

@ssirobertreilly
Copy link
Author

ssirobertreilly commented Jul 7, 2017

sudo /opt/sensu/embedded/bin/gem install sensu-plugins-influxdb -v 1.2.0 --no-rdoc --no-ri
Fetching: influxdb-0.3.13.gem (100%)
Successfully installed influxdb-0.3.13
You can use the embedded Ruby by setting EMBEDDED_RUBY=true in /etc/default/sensu
Successfully installed sensu-plugins-influxdb-1.2.0
2 gems installed
/opt/sensu/embedded/bin/irb
/opt/sensu/embedded/lib/ruby/gems/2.4.0/gems/rb-readline-0.5.3/lib/rbreadline.rb:13: warning: constant ::Fixnum is deprecated
irb(main):001:0> require 'influxdb'
=> true
irb(main):002:0>
ls -al /etc/sensu/extensions/
total 0
drwxr-xr-x 2 sensu sensu 46 Jul  7 10:30 .
drwxr-xr-x 6 sensu sensu 86 Jul  5 10:30 ..
lrwxrwxrwx 1 root  root  57 Jul  7 10:30 mutator-influxdb-line-protocol.rb -> /opt/sensu/embedded/bin/mutator-influxdb-line-protocol.rb

I was running influx udp on 8090 but for the sake of this test i changed it to 8089
Started listening on UDP: :8089 service=udp

handlers.json

{
   "influxdb_udp": {
      "type": "udp",
      "mutator": "influxdb_line_protocol",
      "socket": {
        "host": "localhost",
        "port": 8089
      }
    }
 }

still get the error complaining about "cause" not being found ... ¯\_(ツ)_/¯ . I am going to clean the system of sensu and all gems and try again, I really appreciate your help and will post an update.

@ssirobertreilly
Copy link
Author

strange even though /etc/default/sensu is EMBEDDED_RUBY=true when i install plugins is says You can use the embedded Ruby by setting EMBEDDED_RUBY=true in /etc/default/sensu maybe sensu is not seeing /etc/defaylt/sensu ?

@ssirobertreilly
Copy link
Author

ssirobertreilly commented Jul 7, 2017

whaaat ?
{"timestamp":"2017-07-07T11:03:26.080895-0400","level":"warn","message":"loaded extension","type":"mutator","name":"influxdb_line_protocol","description":"returns check output formatted for InfluxDB's line protocol"}

i will give it some time and validate i am getting data, must have been a bad gem dep when i installed influxdb using gem vs sensu-install. that is only thing I did differently

@ssirobertreilly
Copy link
Author

womp

{"timestamp":"2017-07-07T11:08:51.020539-0400","level":"error","message":"unknown handler","handler_name":"influxdb_udp"}

@ssirobertreilly
Copy link
Author

ok, I got it working once i reinstalled and got rid the ruby dep error, I must have had a typo in the hander. it works now. thanks again for your time.

@eheydrick
Copy link
Contributor

@ssirobertreilly glad it's working for you. Regarding the EMBEDDED_RUBY message on installation - that's output whether you have it enabled already or not. We should probably stop outputting that since it's on by default since 0.21.

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

3 participants