graylog-labs / cli-dashboard

A Graylog stream dashboard that runs in your shell.
http://www.graylog.org
GNU General Public License v3.0
216 stars 31 forks source link

Could not get stream throughput #25

Open xavierhardy opened 8 years ago

xavierhardy commented 8 years ago

When opening a valid stream (I get another error when using an invalid title), I get the following error. The dashboard is not even displayed.

Error: Could not get stream throughput. Bad status code: 404 Not Found [object Object]
    at makeRequest.then.catch (/home/xhardy/Programs/node/lib/node_modules/graylog-cli-dashboard/lib/graylog-api.js:77:13)
    at tryCatcher (/home/xhardy/Programs/node/lib/node_modules/graylog-cli-dashboard/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/xhardy/Programs/node/lib/node_modules/graylog-cli-dashboard/node_modules/bluebird/js/release/promise.js:510:31)
    at Promise._settlePromise (/home/xhardy/Programs/node/lib/node_modules/graylog-cli-dashboard/node_modules/bluebird/js/release/promise.js:567:18)
    at Promise._settlePromise0 (/home/xhardy/Programs/node/lib/node_modules/graylog-cli-dashboard/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/home/xhardy/Programs/node/lib/node_modules/graylog-cli-dashboard/node_modules/bluebird/js/release/promise.js:687:18)
    at Async._drainQueue (/home/xhardy/Programs/node/lib/node_modules/graylog-cli-dashboard/node_modules/bluebird/js/release/async.js:138:16)
    at Async._drainQueues (/home/xhardy/Programs/node/lib/node_modules/graylog-cli-dashboard/node_modules/bluebird/js/release/async.js:148:10)
    at Immediate.Async.drainQueues (/home/xhardy/Programs/node/lib/node_modules/graylog-cli-dashboard/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:637:20)
    at tryOnImmediate (timers.js:610:5)
    at processImmediate [as _immediateCallback] (timers.js:582:5)
xavierhardy commented 8 years ago

Node version v6.9.1, using package version 1.0.0

DerPhlipsi commented 7 years ago

I think know the reason for your problem. graylog-dashboard.js forces the URL to have :12900 in it (see line 92)

// Make sure we have a port (default REST API port is 12900) if (!/:\d+$/.test(config.serverURL)) config.serverURL += ':12900'; // Make sure config.serverURL has a trailing slash. (computers.) if (config.serverURL[config.serverURL.length - 1] !== '/') config.serverURL += '/'; return config });

This is a problem since I (and you probably too) have the Graylog API available at the URL https://graylog.example.com/api/. This can be seen when you add a little debug to the Error message:

Error: Could not get streams. -->url: https://graylog.example.com/api/:12900/streams -->response:

Error: Bad status code: 404 Not Found [object Object] at request.getAsync.then (/usr/lib/node_modules/graylog-cli-dashboard/lib/graylog-api.js:99:13) at tryCatcher (/usr/lib/node_modules/graylog-cli-dashboard/node_modules/bluebird/js/release util.js:16:23)

So the fix for this is to simply comment out line 92 :)

STRML commented 7 years ago

Or add port 443 to your path. Thanks, I'll see what I can do to make this simpler.

On Jan 12, 2017 6:34 AM, "Philipp Ruland" notifications@github.com wrote:

I think know the reason for your problem. graylog-dashboard.js forces the URL to have :12900 in it (see line 92)

// Make sure we have a port (default REST API port is 12900) if (!/:\d+$/.test(config.serverURL)) config.serverURL += ':12900'; // Make sure config.serverURL has a trailing slash. (computers.) if (config.serverURL[config.serverURL.length - 1] !== '/') config.serverURL += '/'; return config });

This is a problem since I (and you probably too) have the Graylog API available at the URL https://graylog.example.com/api/. This can be seen when you add a little debug to the Error message:

Error: Could not get streams. -->url: https://graylog.example.com/api/:12900/streams -->response:

Error: Bad status code: 404 Not Found [object Object] at request.getAsync.then (/usr/lib/node_modules/graylog-cli-dashboard/lib/ graylog-api.js:99:13) at tryCatcher (/usr/lib/node_modules/graylog-cli-dashboard/node_modules/bluebird/js/release util.js:16:23)

So the fix for this is to simply comment out line 92 :)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Graylog2/cli-dashboard/issues/25#issuecomment-272152362, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJFP7Uce-Lt0EUxeKLf7dHm-C47F7Z0ks5rRh3TgaJpZM4KydN9 .

DerPhlipsi commented 7 years ago

Well, that didn't fix it for me. It surprised me too, because the if statement is searching for :. I had to comment out that line to get it to work.

STRML commented 7 years ago

Oh yeah; it's not assuming a path at all... the regex is looking for :\d+$, aka end of string. Would be smarter if it just parsed the url.

It appears there are two configuration options for the API now as of 2.1; separate port, or same port separated by path.

I won't have time for a bit to work on this; would be happy to accept a PR. To be honest, just removing this attempt to be smart would be fine, so long as there's a better error message for when we 404 (something like "is this API URL (${apiURL}) correct?")

DerPhlipsi commented 7 years ago

I'll make a proper fix and open a PR :)

vincebowdrentribal commented 7 years ago

@DerPhlipsi I don't think it is the problem with the server configuration, because if it was then the OP would get a failure on the very first api call made (get /streams), and it would probably be a connection failure. A 404 response means that the connection has been made successfully, and the graylog api server is explicitly returning a 404 for some reason.

@xavierhardy : It's worth running a reverse proxy (e.g. nginx) in front of graylog to find out exactly what the api call is which is failing, and if possible to find out the response details. It might (or might not) be the same problem I've reported in #28.