sensu-plugins / sensu-plugins-graphite

This plugin provides native Graphite instrumentation for monitoring, including: replication status, various Graphite data queries, mutators, and handlers
http://sensu-plugins.io
MIT License
22 stars 45 forks source link

How do we use it? #46

Closed dancb10 closed 6 years ago

dancb10 commented 7 years ago

Hello, There is no clear way on how do we use this plugin. It is installed on server side or client side? Those handlers based on their names just notify the graphite server? But which one is used to send data to graphite? I'm using my sensu server for checks and metrics definition and on my clients I have subscriptions. I have my graphite cluster up and running but I'm not sure what handler script to use on my sensu server and how should be configured to make it communicate with my graphite cluster. I've already configured the metric check on the sensu server so I just need to be able to send data to graphite

dancb10 commented 7 years ago

I've tried creating a file in /etc/sensu/handlers/graphite.json with the following content:

{
  "handlers":
  {
    "graphite": {
       "type": "tcp",
       "socket": {
         "host":"192.168.100.17",
         "port":2003
       },
       "mutator": "only_check_output"
    }
  }
}

But it didn't worked at all. How do I connect the handler with the scripts. And what's the difference between your handlers: handler-graphite-event handler-graphite-occurrences handler-graphite-notify handler-graphite-status

dancb10 commented 7 years ago

I've added two config file like this: [root@dev2-fr1-supervision-03 conf.d]# cat graphite.json

{
  "graphite": {
    "server":"192.168.100.17",
    "port":"2003"
  }
}

[root@dev2-fr1-supervision-03 conf.d]# cat handler_graphite.json

{
  "handlers": {
    "graphite": {
      "type": "pipe",
      "command": "handler-graphite-notify.rb"
    }
  }
}

I've defined the check but now when I'm looking at the logs I see:

{"timestamp":"2017-02-14T16:12:48.121667+0100","level":"info","message":"handler output","handler":{"type":"pipe","command":"handler-graphite-notify.rb","name":"graphite"},"output":["/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-graphite-2.0.0/bin/handler-graphite-notify.rb:14:in `handle': undefined method `[]' for nil:NilClass (NoMethodError)\n\tfrom /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.4.2/lib/sensu-handler.rb:81:in `block in <class:Handler>'\nwarning: event filtering in sensu-plugin is deprecated, see http://bit.ly/sensu-plugin\nwarning: occurrence filtering in sensu-plugin is deprecated, see http://bit.ly/sensu-plugin\n"]}
GhostLyrics commented 7 years ago

Please edit your previous posts to have code in code blocks, this is hardly readable. https://guides.github.com/features/mastering-markdown/ (scroll to syntax highlighting)

The graphite handler is not the best solution at all given it has performance implications. Usage of a TCP handler, as you did in your second comment is preferred. You say this doesn't work. Have you made sure to configure the checks to use the 'graphite' handler?

Here's an example.

{
  "checks": {
    "metrics_uptime": {
      "standalone": true,
      "type": "metric",
      "handlers": [
        "graphite_tcp"
      ],
      "interval": 60,
      "command": "metrics-uptime.rb --scheme sensu.host.$(hostname).uptime",
      "subscribers": [
        "core"
      ]
    }
  }
}
majormoses commented 7 years ago

I suspect the error has to do with the deprecated event filtering in sensu-plugin as indicated by the error message and would only happen on new enough (cant recall off the top of my head and dont feel like digging for exact version) installations of sensu. We might need to bypass the filter in the handler here. I will take a look and see if there is a quick fix for this.

majormoses commented 7 years ago

@dancb10 does the new doc and the examples here help? Just checking if there is anything else we need to do.

majormoses commented 6 years ago

closing as we have enhanced this and there is a lack of response to clarify if anything else is needed.