mallocator/Elasticsearch-Exporter

Caught exception in Main process: TypeError: Cannot read property 'hits' of undefined

MaximF opened this issue · 7 comments

Have a ES cluster hosted with qbox.io. They use port 80 and 443 to connect to a cluster.
Elasticsearch-Exporter 1.4.0 fails when trying to use other than a default port.

Here is a timing out because there is no connection available on port 9200

# nodejs exporter.js -a localhost -b HOSTNAME.qbox.io
Elasticsearch Exporter - Version 1.4.0
Reading source statistics from ElasticSearch
connect ETIMEDOUT
connect ETIMEDOUT
connect ETIMEDOUT
connect ETIMEDOUT
Number of calls:        0
Fetched Entries:        0 documents
Processed Entries:      0 documents
Source DB Size:         0 documents

And applying port 80 on target host

# nodejs exporter.js -a localhost -b HOSTNAME.qbox.io -q 80
Elasticsearch Exporter - Version 1.4.0
Reading source statistics from ElasticSearch
Reading mapping from ElasticSearch
Caught exception in Main process: TypeError: Cannot read property 'hits' of undefined
TypeError: Cannot read property 'hits' of undefined
    at IncomingMessage.<anonymous> (/root/Elasticsearch-Exporter/drivers/es.js:542:31)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)
Number of calls:        0
Fetched Entries:        0 documents
Processed Entries:      0 documents
Source DB Size:         0 documents

Tried couple different versions down to 1.1.4, still not working.

Please advice.

Can you check if scanning works and run something like

curl 'http://api_token.api.qbox.io/index_name/_search?scroll=5m' -d '{"query":{"match_all":{}}}

I'm not sure what the problem is, but maybe qbox doesn't support all functions?
Maybe you have to go index by index?

@mallocator
request you have mentioned is working for qbox.
An issue appeared when I was trying to use port 80 to migrate all indexes.

At this moment I have solved a problem, by migrating data index-by-index using a native ES tools.

But it would be nice if you ElasticSearch exporter would be working with different ports, as it seems to eb a nice tool overall.

I don't think the issue is with the ports because that usually works.

Have you tried using the exporter just on an index instead of the entire cluster? I don't know qbox, but I've seen with hosted instances often the issue that you can't run operations on cluster level, only on index level.

jla commented

I've got this problem running a Nginx proxy in front of elasticsearch, the POST requests are sent without the Content-length header and Nginx respond with a 411 Length Required.

In the code the content-length is setup correctly but the headers are never pass to the request

Maybe i'm missing something else but this change works for me:

--- a/drivers/es.js
+++ b/drivers/es.js
@@ -76,6 +76,7 @@ var request = new function() {
             port: port,
             path: path,
             auth: auth,
+            headers: headers,
             method: method
         };
         if (httpProxy) {

You're absolutely right, thanks for catching that. The fix has been pushed to master.

jla commented

Thank to you for this project, It has been really useful for me

You're welcome. Glad you like it.