eksoverzero / newrelic_elasticsearch_agent

Elasticsearch monitoring through New Relic
MIT License
21 stars 14 forks source link

undefined method `[]' for nil:NilClass #2

Closed igoratencompass closed 11 years ago

igoratencompass commented 11 years ago

Now I'm getting the following error:

./newrelic_elasticsearch_agent

[Sun Sep 22 00:42:53 UTC 2013] WARN: SSL is disabled by default when using Ruby 1.8.x [Sun Sep 22 00:42:53 UTC 2013] INFO: Using Ruby SDK version: 1.2.1 [Sun Sep 22 00:42:53 UTC 2013] INFO: Agent ElasticSearch is at version 0.0.1 [Sun Sep 22 00:42:53 UTC 2013] DEBUG: Start collecting agent data for poll cycle [Sun Sep 22 00:42:53 UTC 2013] ERROR: Error occurred in poll cycle: undefined method `[]' for nil:NilClass [Sun Sep 22 00:42:53 UTC 2013] DEBUG: Finished collecting agent data for poll cycle [Sun Sep 22 00:42:53 UTC 2013] WARN: Component with name "db11-prod" and guid "com.secondimpression.newrelic-elasticsearch-agent" had no metrics [Sun Sep 22 00:42:53 UTC 2013] DEBUG: JSON payload: {"components":[{"duration":60,"metrics":{},"name":"db11-prod","guid":"com.secondimpression.newrelic-elasticsearch-agent"}],"agent":{"version":"0.0.1"}} [Sun Sep 22 00:42:53 UTC 2013] INFO: Gathered 0 statistics from 0 components

Looks like variable discrepancy like sending array to a string or something.

ruby -v

ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

Thanks, Igor

eksoverzero commented 11 years ago

Hi,

Can you please paste your config file?

Sent from MobileToaster

On 22 Sep 2013, at 2:48, igorcatportland notifications@github.com wrote:

Now I'm getting the following error:

./newrelic_elasticsearch_agent

[Sun Sep 22 00:42:53 UTC 2013] WARN: SSL is disabled by default when using Ruby 1.8.x [Sun Sep 22 00:42:53 UTC 2013] INFO: Using Ruby SDK version: 1.2.1 [Sun Sep 22 00:42:53 UTC 2013] INFO: Agent ElasticSearch is at version 0.0.1 [Sun Sep 22 00:42:53 UTC 2013] DEBUG: Start collecting agent data for poll cycle [Sun Sep 22 00:42:53 UTC 2013] ERROR: Error occurred in poll cycle: undefined method `[]' for nil:NilClass [Sun Sep 22 00:42:53 UTC 2013] DEBUG: Finished collecting agent data for poll cycle [Sun Sep 22 00:42:53 UTC 2013] WARN: Component with name "db11-prod" and guid "com.secondimpression.newrelic-elasticsearch-agent" had no metrics [Sun Sep 22 00:42:53 UTC 2013] DEBUG: JSON payload: {"components":[{"duration":60,"metrics":{},"name":"db11-prod","guid":"com.secondimpression.newrelic-elasticsearch-agent"}],"agent":{"version":"0.0.1"}} [Sun Sep 22 00:42:53 UTC 2013] INFO: Gathered 0 statistics from 0 components

Looks like variable discrepancy like sending array to a string or something.

ruby -v

ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

Thanks, Igor

— Reply to this email directly or view it on GitHub.

igoratencompass commented 11 years ago

agents: elasticsearch_stats_agent:

  name: "db11-prod"
  index: "searches"
  url: "http://localhost:9200"
eksoverzero commented 11 years ago

I get the same error when I set the wrong index name in the config

...
ERROR while gathering stats from http://localhost:9200: 404 Not Found
[Tue Sep 24 18:48:07 UTC 2013] ERROR: Error occurred in poll cycle: undefined method `[]' for nil:NilClass
...

If the index name is correct your side, can you please send me a redacted version of: http://localhost:9200/searches/_stats (Based on your config file)

I can only replicate the error, as mentioned above, when using the incorrect index name

trojas commented 11 years ago

I'm encountering the same error. Here's some info on my setup. I can see the tab in New Relic, so it's getting there OK. Just no stats being sent across.

trojas$ bundle exec ./newrelic_elasticsearch_agent [2013-09-24 21:21:11 UTC] INFO: Using Ruby SDK version: 1.2.1 [2013-09-24 21:21:11 UTC] INFO: Agent ElasticSearch is at version 0.0.1 [2013-09-24 21:21:11 UTC] DEBUG: Start collecting agent data for poll cycle [2013-09-24 21:21:11 UTC] ERROR: Error occurred in poll cycle: undefined method `[]' for nil:NilClass [2013-09-24 21:21:11 UTC] DEBUG: Finished collecting agent data for poll cycle [2013-09-24 21:21:11 UTC] WARN: Component with name "local" and guid "com.secondimpression.newrelic-elasticsearch-agent" had no metrics [2013-09-24 21:21:11 UTC] DEBUG: JSON payload: {"agent":{"version":"0.0.1"},"components":[{"name":"local","guid":"com.secondimpression.newrelic-elasticsearch-agent","duration":60,"metrics":{}}]} [2013-09-24 21:21:11 UTC] INFO: Gathered 0 statistics from 0 components

ruby -v ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin10.8.0]

bundle -v Bundler version 1.3.5

ElasticSearch 0.90.5

Config file agents: elasticsearch_stats_agent:

  name: "local"
  index: "test"
  url: "http://localhost:9200"

http://localhost:9200/test/_stats {

"ok": true,
"_shards": {
    "total": 10,
    "successful": 5,
    "failed": 0
},
"_all": {
    "primaries": {
        "docs": {
            "count": 3,
            "deleted": 0
        },
        "store": {
            "size": "6.7kb",
            "size_in_bytes": 6883,
            "throttle_time": "0s",
            "throttle_time_in_millis": 0
        },
        "indexing": {
            "index_total": 3,
            "index_time": "12ms",
            "index_time_in_millis": 12,
            "index_current": 0,
            "delete_total": 0,
            "delete_time": "0s",
            "delete_time_in_millis": 0,
            "delete_current": 0
        },
        "get": {
            "total": 2,
            "get_time": "0s",
            "time_in_millis": 0,
            "exists_total": 2,
            "exists_time": "0s",
            "exists_time_in_millis": 0,
            "missing_total": 0,
            "missing_time": "0s",
            "missing_time_in_millis": 0,
            "current": 0
        },
        "search": {
            "open_contexts": 0,
            "query_total": 0,
            "query_time": "0s",
            "query_time_in_millis": 0,
            "query_current": 0,
            "fetch_total": 0,
            "fetch_time": "0s",
            "fetch_time_in_millis": 0,
            "fetch_current": 0
        }
    },
    "total": {
        "docs": {
            "count": 3,
            "deleted": 0
        },
        "store": {
            "size": "6.7kb",
            "size_in_bytes": 6883,
            "throttle_time": "0s",
            "throttle_time_in_millis": 0
        },
        "indexing": {
            "index_total": 3,
            "index_time": "12ms",
            "index_time_in_millis": 12,
            "index_current": 0,
            "delete_total": 0,
            "delete_time": "0s",
            "delete_time_in_millis": 0,
            "delete_current": 0
        },
        "get": {
            "total": 2,
            "get_time": "0s",
            "time_in_millis": 0,
            "exists_total": 2,
            "exists_time": "0s",
            "exists_time_in_millis": 0,
            "missing_total": 0,
            "missing_time": "0s",
            "missing_time_in_millis": 0,
            "current": 0
        },
        "search": {
            "open_contexts": 0,
            "query_total": 0,
            "query_time": "0s",
            "query_time_in_millis": 0,
            "query_current": 0,
            "fetch_total": 0,
            "fetch_time": "0s",
            "fetch_time_in_millis": 0,
            "fetch_current": 0
        }
    }
},
"indices": {
    "test": {
        "primaries": {
            "docs": {
                "count": 3,
                "deleted": 0
            },
            "store": {
                "size": "6.7kb",
                "size_in_bytes": 6883,
                "throttle_time": "0s",
                "throttle_time_in_millis": 0
            },
            "indexing": {
                "index_total": 3,
                "index_time": "12ms",
                "index_time_in_millis": 12,
                "index_current": 0,
                "delete_total": 0,
                "delete_time": "0s",
                "delete_time_in_millis": 0,
                "delete_current": 0
            },
            "get": {
                "total": 2,
                "get_time": "0s",
                "time_in_millis": 0,
                "exists_total": 2,
                "exists_time": "0s",
                "exists_time_in_millis": 0,
                "missing_total": 0,
                "missing_time": "0s",
                "missing_time_in_millis": 0,
                "current": 0
            },
            "search": {
                "open_contexts": 0,
                "query_total": 0,
                "query_time": "0s",
                "query_time_in_millis": 0,
                "query_current": 0,
                "fetch_total": 0,
                "fetch_time": "0s",
                "fetch_time_in_millis": 0,
                "fetch_current": 0
            }
        },
        "total": {
            "docs": {
                "count": 3,
                "deleted": 0
            },
            "store": {
                "size": "6.7kb",
                "size_in_bytes": 6883,
                "throttle_time": "0s",
                "throttle_time_in_millis": 0
            },
            "indexing": {
                "index_total": 3,
                "index_time": "12ms",
                "index_time_in_millis": 12,
                "index_current": 0,
                "delete_total": 0,
                "delete_time": "0s",
                "delete_time_in_millis": 0,
                "delete_current": 0
            },
            "get": {
                "total": 2,
                "get_time": "0s",
                "time_in_millis": 0,
                "exists_total": 2,
                "exists_time": "0s",
                "exists_time_in_millis": 0,
                "missing_total": 0,
                "missing_time": "0s",
                "missing_time_in_millis": 0,
                "current": 0
            },
            "search": {
                "open_contexts": 0,
                "query_total": 0,
                "query_time": "0s",
                "query_time_in_millis": 0,
                "query_current": 0,
                "fetch_total": 0,
                "fetch_time": "0s",
                "fetch_time_in_millis": 0,
                "fetch_current": 0
            }
        }
    }
}

}

trojas commented 11 years ago

Thanks for the quick reply. I tried to apply the fix but it didn't work. I think I found the issue though. It related to these two lines:

   stats = json["_all"]
   stats = json["_all"]["indices"]["#{index}"] unless index == "_all" 

Basically when I review the _stats response, "indices" appears on the same level as "_all". It is not under it. So if I make this code modification, it works:

   stats = json["_all"]
   stats = json["indices"]["#{index}"] unless index == "_all" 

So far I am successfully seeing stats being sent to New Relic. I'll keep running it for a bit and let you know if anything else comes up.

Thanks for your time and contributing this! It's nice to see the info in New Relic. :)

igoratencompass commented 11 years ago

For me the indices are bellow "_all" as they should be I suppose. Putting "_all" in the config file solved the issue for me. Thanks for your support.

emas80 commented 11 years ago

Hi, I'm having what I think it is a similar issue. Launching the agent from command line:

bundle exec ./newrelic_elasticsearch_agent [2013-09-26 10:45:34 UTC] INFO: Using Ruby SDK version: 1.2.1 [2013-09-26 10:45:34 UTC] INFO: Agent ElasticSearch is at version 0.0.1 [2013-09-26 10:45:34 UTC] DEBUG: Start collecting agent data for poll cycle ERROR while gathering stats from http://localhost:9200: undefined method `empty?' for #URI::HTTP:0x000000029413d8 [2013-09-26 10:45:34 UTC] ERROR: Error occurred in poll cycle: can't convert nil into String [2013-09-26 10:45:34 UTC] DEBUG: Finished collecting agent data for poll cycle [2013-09-26 10:45:34 UTC] WARN: Component with name "Faceit ES" and guid "com.secondimpression.newrelic-elasticsearch-agent" had no metrics [2013-09-26 10:45:34 UTC] DEBUG: JSON payload: {"agent":{"version":"0.0.1"},"components":[{"name":"Faceit ES","guid":"com.secondimpression.newrelic-elasticsearch-agent","duration":60,"metrics":{}}]} [2013-09-26 10:45:34 UTC] INFO: Gathered 0 statistics from 0 components

My config in new_relic_plugin.yml is: elasticsearch_stats_agent:

  name: "Faceit ES"
  index: "quickmatches"
  url: "http://localhost:9200"

And giving curl http://localhost:9200/quickmatches/_stats {"ok":true,"_shards":{"total":10,"successful":5,"failed":0},"_all":{"primaries":{"docs":{"count":14,"deleted":0},"store":{"size":"16.8kb","size_in_bytes":17268,"throttle_time":"0s","throttle_time_in_millis":0},"indexing":{"index_total":0,"index_time":"0s","index_time_in_millis":0,"index_current":0,"delete_total":0,"delete_time":"0s","delete_time_in_millis":0,"delete_current":0},"get":{"total":0,"time":"0s","time_in_millis":0,"exists_total":0,"exists_time":"0s","exists_time_in_millis":0,"missing_total":0,"missing_time":"0s","missing_time_in_millis":0,"current":0},"search":{"query_total":0,"query_time":"0s","query_time_in_millis":0,"query_current":0,"fetch_total":0,"fetch_time":"0s","fetch_time_in_millis":0,"fetch_current":0}},"total":{"docs":{"count":14,"deleted":0},"store":{"size":"16.8kb","size_in_bytes":17268,"throttle_time":"0s","throttle_time_in_millis":0},"indexing":{"index_total":0,"index_time":"0s","index_time_in_millis":0,"index_current":0,"delete_total":0,"delete_time":"0s","delete_time_in_millis":0,"delete_current":0},"get":{"total":0,"time":"0s","time_in_millis":0,"exists_total":0,"exists_time":"0s","exists_time_in_millis":0,"missing_total":0,"missing_time":"0s","missing_time_in_millis":0,"current":0},"search":{"query_total":0,"query_time":"0s","query_time_in_millis":0,"query_current":0,"fetch_total":0,"fetch_time":"0s","fetch_time_in_millis":0,"fetch_current":0}},"indices":{"quickmatches":{"primaries":{"docs":{"count":14,"deleted":0},"store":{"size":"16.8kb","size_in_bytes":17268,"throttle_time":"0s","throttle_time_in_millis":0},"indexing":{"index_total":0,"index_time":"0s","index_time_in_millis":0,"index_current":0,"delete_total":0,"delete_time":"0s","delete_time_in_millis":0,"delete_current":0},"get":{"total":0,"time":"0s","time_in_millis":0,"exists_total":0,"exists_time":"0s","exists_time_in_millis":0,"missing_total":0,"missing_time":"0s","missing_time_in_millis":0,"current":0},"search":{"query_total":0,"query_time":"0s","query_time_in_millis":0,"query_current":0,"fetch_total":0,"fetch_time":"0s","fetch_time_in_millis":0,"fetch_current":0}},"total":{"docs":{"count":14,"deleted":0},"store":{"size":"16.8kb","size_in_bytes":17268,"throttle_time":"0s","throttle_time_in_millis":0},"indexing":{"index_total":0,"index_time":"0s","index_time_in_millis":0,"index_current":0,"delete_total":0,"delete_time":"0s","delete_time_in_millis":0,"delete_current":0},"get":{"total":0,"time":"0s","time_in_millis":0,"exists_total":0,"exists_time":"0s","exists_time_in_millis":0,"missing_total":0,"missing_time":"0s","missing_time_in_millis":0,"current":0},"search":{"query_total":0,"query_time":"0s","query_time_in_millis":0,"query_current":0,"fetch_total":0,"fetch_time":"0s","fetch_time_in_millis":0,"fetch_current":0}}}}}}

Here on localhost I'm using 0.20 version, but on production environment I'm using the 0.90.x and the result is the same, I can set up locally the 0.90 but I can't see how it would help.

eksoverzero commented 11 years ago

Is this error from the issue_2 or master branch?

emas80 commented 11 years ago

Master branch. But after the last deploy of the application on production for installing another plugin, it suddenly appeared a label "ElasticSearch" in the left column, also if when I click I see a grey column instead of a green one.

eksoverzero commented 11 years ago

There are fixes in the issue_2 branch, latest being pushed this morning. I'm just waiting on a confirmation before merging it again into the master and releasing it.

emas80 commented 11 years ago

Ok, thank you