Closed adityanmishra closed 1 year ago
@mfilotto Have a second to help us understand what might be going on here?
I just had the same issue und found the cause for my case: The hubot-grafana coffee scripts tries to login to Rocket.Chat using an URL that is prefixed with http:// instead of https://. For our configuration this will lead to an HTTP 301 (redirecting to the https endpoint) and a response document with HTML in it, which is then parsed to JSON - which fails with the error message above.
I configured my Hubot Rocket.Chat adapter using ROCKETCHAT_URL=chat.myhost.com and ROCKETCHAT_USE_SSL=true, but this is obviously ignored by hubot-grafana.
So I changed the the value of ROCKETCHAT_URL to https://chat.myhost.com and now hubot-grafana is using the correct protocol.
@mechko I think we can rely on whatever settings are needed by the Rocket.Chat adapter, given this is an integration specific to that platform. Do you think we should leverage ROCKETCHAT_USE_SSL
for easier set up?
I think we should stick to URL definition: scheme:[//authority]path[?query][#fragment] If so the protocol should be specify, even if the default is http if not specify.
Otherwise we could add these two variables ROCKETCHAT_HOST and ROCKETCHAT_USE_SSL
👍 It appears to be something defined for the lower level SDK. I agree the URL is a much cleaner way to define it. The "fix" for this bug (aside from defining the ROCKETCHAT_HOST
with the scheme) is to see if we can handle the error a bit more gracefully than the SyntaxError
it throws when encountering the redirect.
Describe the bug when running hubot graf db test123 hubot-rocketchat is showing ERROR SyntaxError: Unexpected token <
My grafana url is https://test.tools.**.**/grafana
I get below log from hubot container DEBUG [ 'hubot graf db test123', 'test123', undefined, index: 0, input: 'hubot graf db test123' ]
DEBUG { meta: { type: 'db', canSave: false, canEdit: false, canAdmin: false, canStar: false, slug: 'test123', url: '/grafana/d/VKZr7u9mz/test123', expires: '0001-01-01T00:00:00Z', created: '2019-02-27T21:26:21Z', updated: '2019-02-27T21:26:21Z', updatedBy: 'admin', createdBy: 'admin', version: 1, hasAcl: false, isFolder: false, folderId: 0, folderTitle: 'General', folderUrl: '', provisioned: false }, dashboard: { annotations: { list: [Object] }, editable: true, gnetId: null, graphTooltip: 0, hideControls: false, id: 26, links: [], panels: [ [Object] ], schemaVersion: 16, style: 'dark', tags: [], templating: { list: [] }, time: { from: 'now-6h', to: 'now' }, timepicker: { refresh_intervals: [Object], time_options: [Object] }, timezone: '', title: 'test123', uid: 'VKZr7u9mz', version: 1 } }
DEBUG { cacheTimeout: null, colorBackground: false, colorValue: false, colors: [ '#299c46', 'rgba(237, 129, 40, 0.89)', '#d44a3a' ], format: 'none', gauge: { maxValue: 100, minValue: 0, show: false, thresholdLabels: false, thresholdMarkers: true }, gridPos: { h: 9, w: 12, x: 0, y: 0 }, id: 2, interval: null, links: [], mappingType: 1, mappingTypes: [ { name: 'value to text', value: 1 }, { name: 'range to text', value: 2 } ], maxDataPoints: 100, nullPointMode: 'connected', nullText: null, postfix: '', postfixFontSize: '50%', prefix: '', prefixFontSize: '50%', rangeMaps: [ { from: 'null', text: 'N/A', to: 'null' } ], sparkline: { fillColor: 'rgba(31, 118, 189, 0.18)', full: false, lineColor: 'rgb(31, 120, 193)', show: false }, tableColumn: '', targets: [ { expr: '150', format: 'time_series', intervalFactor: 1, refId: 'A' } ], thresholds: '', title: 'test123', type: 'singlestat', valueFontSize: '80%', valueMaps: [ { op: '=', text: 'N/A', value: 'null' } ], valueName: 'avg' } [Wed Feb 27 2019 23:02:18 GMT+0000 (UTC)] ERROR SyntaxError: Unexpected token < at Object.parse (native) at Request._callback (/home/hubot/node_modules/hubot-grafana/src/grafana.coffee:485:27) at Request.self.callback (/home/hubot/node_modules/hubot-grafana/node_modules/request/request.js:185:22) at emitTwo (events.js:87:13) at Request.emit (events.js:172:7) at Request. (/home/hubot/node_modules/hubot-grafana/node_modules/request/request.js:1161:10)
at emitOne (events.js:77:13)
at Request.emit (events.js:169:7)
at IncomingMessage. (/home/hubot/node_modules/hubot-grafana/node_modules/request/request.js:1083:12)
at IncomingMessage.g (events.js:260:16)
at emitNone (events.js:72:20)
at IncomingMessage.emit (events.js:166:7)
at endReadableNT (_stream_readable.js:923:12)
at nextTickCallbackWith2Args (node.js:511:9)
at process._tickCallback (node.js:425:17)
To Reproduce Create a small dashboard in grafana. Grafana has url /grafana. Enabled anonymus in grafana
Started hubot-rocketchat with below options
In rocketchat room when i do hubot graf db anyname I get the above error. But graf list command works fine
Expected behavior Image should be shown in rocketchat
Screenshots If applicable, add screenshots to help explain your problem.
Software:
Additional context We are running rocketchat and grafana in kubernetes.