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

metrics-http-json-deep.rb not working #48

Open
dosullivan opened this issue Aug 4, 2016 · 3 comments
Open

metrics-http-json-deep.rb not working #48

dosullivan opened this issue Aug 4, 2016 · 3 comments

Comments

@dosullivan
Copy link

I've been having a difficult time with the metrics-http-json-deep.rb check. I am trying to use it to collect metrics reported in JSON over HTTP in order to send them to graphite. When I run it against a simple JSON message with just two key/value pairs (like http://echo.jsontest.com/key/value/one/two), I get the following error:

Check failed to run: undefined method each' for nil:NilClass, ["/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-1.0.0/bin/metrics-http-json-deep.rb:81:in deep_value'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-1.0.0/bin/metrics-http-json-deep.rb:119:in run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/cli.rb:56:in block in <class:CLI>'"]

With more complex JSON messages, such as the output I'm actually trying to record, I get this error:

Check failed to run: no implicit conversion of Regexp into String, ["/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-1.0.0/bin/metrics-http-json-deep.rb:82:in tr'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-1.0.0/bin/metrics-http-json-deep.rb:82:in block in deep_value'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-1.0.0/bin/metrics-http-json-deep.rb:81:in each'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-1.0.0/bin/metrics-http-json-deep.rb:81:in deep_value'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-1.0.0/bin/metrics-http-json-deep.rb:119:in run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.2.0/lib/sensu-plugin/cli.rb:56:in block in <class:CLI>'"]

I installed the check using sensu-install, if that helps. Any idea what the issue could be here? Would greatly appreciate any help debugging this.

@ghettodev
Copy link

For anyone else who is googling this:

Source:

curl -s http://0.0.0.0:9292/health| python -mjson.tool 
{
    "queue_depth": {
        "connector_worker_pool": 0,
        "publisher_pool": 0,
        "status_updater_pool": 0
    }
}

Error:

metrics-http-json-deep.rb --url http://0.0.0.0:9292/health
Check failed to run: undefined method `each' for nil:NilClass, ["/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-1.0.0/bin/metrics-http-json-deep.rb:81:in `deep_value'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-http-1.0.0/bin/metrics-http-json-deep.rb:129:in `run'", "/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugin-1.3.0/lib/sensu-plugin/cli.rb:57:in `block in <class:CLI>'"]

Solution:

metrics-http-json-deep.rb --port 9292 --path health --root 'queue_depth' 
ubuntu.json.connector_worker_pool 0 1470950544
ubuntu.json.publisher_pool 0 1470950544
ubuntu.json.status_updater_pool 0 1470950544

@nevins-b nevins-b mentioned this issue Mar 3, 2017
8 tasks
@majormoses
Copy link
Member

Is this still an issue?

@majormoses
Copy link
Member

@ghettodev could you put together a pr to document this useage?

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

4 participants