cli-dashboard icon indicating copy to clipboard operation
cli-dashboard copied to clipboard

Could not get stream throughput

Open xavierhardy opened this issue 8 years ago • 7 comments

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 avatar Nov 15 '16 12:11 xavierhardy

Node version v6.9.1, using package version 1.0.0

xavierhardy avatar Nov 15 '16 12:11 xavierhardy

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 :)

DerPhlipsi avatar Jan 12 '17 12:01 DerPhlipsi

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" [email protected] 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 .

STRML avatar Jan 12 '17 14:01 STRML

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.

DerPhlipsi avatar Jan 12 '17 17:01 DerPhlipsi

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?")

STRML avatar Jan 12 '17 18:01 STRML

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

DerPhlipsi avatar Jan 13 '17 15:01 DerPhlipsi

@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.

vincebowdrentribal avatar Feb 02 '17 15:02 vincebowdrentribal