Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error getting dashboard #19

Closed
Seraf opened this issue Oct 16, 2015 · 12 comments
Closed

Error getting dashboard #19

Seraf opened this issue Oct 16, 2015 · 12 comments
Assignees
Labels

Comments

@Seraf
Copy link

Seraf commented Oct 16, 2015

Hello,

First, thanks for this project ! 👍

Grafana version : 2.1.3

I have an error trying to get panels :

Julien Syx [11:30] 
hubot graf list

hubotBOT [11:30] 
Available dashboards:
- test-machine: Test machine
- test-dashboard: Test dashboard

Julien Syx [11:31] 
hubot graf db test-machine

Then hubot answers nothing and in the log I get :

[Fri Oct 16 2015 11:31:30 GMT+0200 (CEST)] ERROR TypeError: Cannot read property 'text' of undefined
  at /home/admin/hubot/node_modules/hubot-grafana/src/grafana.coffee:113:11, <js>:82:65
  at /home/admin/hubot/node_modules/hubot-grafana/src/grafana.coffee:202:14, <js>:178:16
  at IncomingMessage.<anonymous> (/home/admin/hubot/node_modules/hubot/node_modules/scoped-http-client/src/index.js:95:22)
  at emitNone (events.js:72:20)
  at IncomingMessage.emit (events.js:166:7)
  at endReadableNT (_stream_readable.js:903:12)
  at doNTCallback2 (node.js:439:9)
  at process._tickCallback (node.js:353:17)

But test-dahboard works correctly. I thought it was the parameter $SERVER which was missing, but adding this parameter give exactly the same error

Any idea about this please ?
Thanks

@stephenyeargin
Copy link
Owner

/cc @Tenzer / @torkelo

Trouble appears to be https://github.com/stephenyeargin/hubot-grafana/blob/master/src/grafana.coffee#L113 that perhaps the template .text property is not set? Not aware of an API change in that particular version.

@stephenyeargin
Copy link
Owner

@Seraf can you set:

HUBOT_LOG_LEVEL=debug

and see what the output looks like from around that line? I'm curious what those template objects look like from your install.

@Seraf
Copy link
Author

Seraf commented Oct 19, 2015

@stephenyeargin :

[Mon Oct 19 2015 18:56:16 GMT+0200 (CEST)] DEBUG Message '@cyclobot-customer: graf db cycloid-machine' matched regex //^\s*[@]?cyclobot\-customer[:,]?\s*(?:(?:grafana|graph|graf) (?:dash|dashboard|db) ([A-Za-z0-9\-\:_]+)(.*)?)/i/
[Mon Oct 19 2015 18:56:16 GMT+0200 (CEST)] DEBUG Executing listener callback for Message '@cyclobot-customer: graf db cycloid-machine'
[Mon Oct 19 2015 18:56:16 GMT+0200 (CEST)] DEBUG [ '@cyclobot-customer: graf db cycloid-machine',
  'cycloid-machine',
  undefined,
  index: 0,
  input: '@cyclobot-customer: graf db cycloid-machine' ]
[Mon Oct 19 2015 18:56:16 GMT+0200 (CEST)] DEBUG cycloid-machine
[Mon Oct 19 2015 18:56:16 GMT+0200 (CEST)] DEBUG { from: 'now-6h', to: 'now' }
[Mon Oct 19 2015 18:56:16 GMT+0200 (CEST)] DEBUG 
[Mon Oct 19 2015 18:56:16 GMT+0200 (CEST)] DEBUG false
[Mon Oct 19 2015 18:56:16 GMT+0200 (CEST)] DEBUG false
[Mon Oct 19 2015 18:56:16 GMT+0200 (CEST)] DEBUG { meta: 
   { type: 'db',
     canSave: false,
     canEdit: false,
     canStar: true,
     slug: 'cycloid-machine',
     expires: '0001-01-01T00:00:00Z',
     created: '0001-01-01T00:00:00Z' },
  dashboard: 
   { annotations: { list: [] },
     editable: true,
     hideControls: false,
     id: 24,
     links: [],
     nav: [ [Object] ],
     originalTitle: 'Test',
     rows: [ [Object] ],
     schemaVersion: 6,
     sharedCrosshair: false,
     style: 'dark',
     tags: [],
     templating: { list: [Object] },
     time: { from: 'now-6h', to: 'now' },
     timezone: 'browser',
     title: '[CYCLOID] Machine',
     version: 1 } }
[Mon Oct 19 2015 18:56:16 GMT+0200 (CEST)] DEBUG [ { allFormat: 'glob',
    datasource: null,
    includeAll: false,
    multi: false,
    multiFormat: 'glob',
    name: 'SERVER',
    options: [],
    query: 'CUSTOMER-*',
    refresh: true,
    refresh_on_load: true,
    type: 'query' },
  { allFormat: 'glob',
    current: { tags: [], text: '1m', value: '1m' },
    datasource: null,
    includeAll: false,
    multi: false,
    multiFormat: 'glob',
    name: 'summarize',
    options: 
     [ [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object] ],
    query: '1m,10m,30m,1h,6h,12h,1d,7d,14d,30d',
    refresh_on_load: false,
    type: 'interval' } ]
[Mon Oct 19 2015 18:56:16 GMT+0200 (CEST)] ERROR TypeError: Cannot read property 'text' of undefined
  at /home/admin/hubot-customer/node_modules/hubot-grafana/src/grafana.coffee:113:11, <js>:82:65
  at /home/admin/hubot-customer/node_modules/hubot-grafana/src/grafana.coffee:202:14, <js>:178:16
  at IncomingMessage.<anonymous> (/home/admin/hubot-customer/node_modules/hubot/node_modules/scoped-http-client/src/index.js:95:22)
  at emitNone (events.js:72:20)
  at IncomingMessage.emit (events.js:166:7)
  at endReadableNT (_stream_readable.js:903:12)
  at doNTCallback2 (node.js:439:9)
  at process._tickCallback (node.js:353:17)

@stephenyeargin
Copy link
Owner

Well, that wasn't as helpful as I'd hoped it would be. 😞

The JSON response is coming back missing that property, but it seems like that's the most critical piece of information for selecting a templated Dashboard (which you don't appear to be using based on your query). I'll need to dig deeper into it, or at least add more sanity checks around those lines of code to ensure the property exists before trying to use it.

@Seraf
Copy link
Author

Seraf commented Oct 19, 2015

@stephenyeargin if it can help, here the debug with my variable :

[Mon Oct 19 2015 21:02:10 GMT+0200 (CEST)] DEBUG Received message: '@cyclobot-customer: graf db cycloid-machine SERVER=CUSTOMER-BASTION0-EU-WE1-PROD' in channel: testjsyx, from: cycloid_seraf
[Mon Oct 19 2015 21:02:10 GMT+0200 (CEST)] DEBUG Message '@cyclobot-customer: graf db cycloid-machine SERVER=CUSTOMER-BASTION0-EU-WE1-PROD' matched regex //^\s*[@]?cyclobot\-customer[:,]?\s*(?:(?:grafana|graph|graf) (?:dash|dashboard|db) ([A-Za-z0-9\-\:_]+)(.*)?)/i/
[Mon Oct 19 2015 21:02:10 GMT+0200 (CEST)] DEBUG Executing listener callback for Message '@cyclobot-customer: graf db cycloid-machine SERVER=CUSTOMER-BASTION0-EU-WE1-PROD'
[Mon Oct 19 2015 21:02:10 GMT+0200 (CEST)] DEBUG [ '@cyclobot-customer: graf db cycloid-machine SERVER=CUSTOMER-BASTION0-EU-WE1-PROD',
  'cycloid-machine',
  ' SERVER=CUSTOMER-BASTION0-EU-WE1-PROD',
  index: 0,
  input: '@cyclobot-customer: graf db cycloid-machine SERVER=CUSTOMER-BASTION0-EU-WE1-PROD' ]
[Mon Oct 19 2015 21:02:10 GMT+0200 (CEST)] DEBUG cycloid-machine
[Mon Oct 19 2015 21:02:10 GMT+0200 (CEST)] DEBUG { from: 'now-6h', to: 'now' }
[Mon Oct 19 2015 21:02:10 GMT+0200 (CEST)] DEBUG &var-SERVER=CUSTOMER-BASTION0-EU-WE1-PROD
[Mon Oct 19 2015 21:02:10 GMT+0200 (CEST)] DEBUG false
[Mon Oct 19 2015 21:02:10 GMT+0200 (CEST)] DEBUG false
[Mon Oct 19 2015 21:02:10 GMT+0200 (CEST)] DEBUG { meta: 
   { type: 'db',
     canSave: false,
     canEdit: false,
     canStar: true,
     slug: 'cycloid-machine',
     expires: '0001-01-01T00:00:00Z',
     created: '0001-01-01T00:00:00Z' },
  dashboard: 
   { annotations: { list: [] },
     editable: true,
     hideControls: false,
     id: 24,
     links: [],
     nav: [ [Object] ],
     originalTitle: 'Test',
     rows: [ [Object] ],
     schemaVersion: 6,
     sharedCrosshair: false,
     style: 'dark',
     tags: [],
     templating: { list: [Object] },
     time: { from: 'now-6h', to: 'now' },
     timezone: 'browser',
     title: '[CYCLOID] Machine',
     version: 1 } }
[Mon Oct 19 2015 21:02:10 GMT+0200 (CEST)] DEBUG [ { allFormat: 'glob',
    datasource: null,
    includeAll: false,
    multi: false,
    multiFormat: 'glob',
    name: 'SERVER',
    options: [],
    query: 'CUSTOMER-*',
    refresh: true,
    refresh_on_load: true,
    type: 'query' },
  { allFormat: 'glob',
    current: { tags: [], text: '1m', value: '1m' },
    datasource: null,
    includeAll: false,
    multi: false,
    multiFormat: 'glob',
    name: 'summarize',
    options: 
     [ [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object] ],
    query: '1m,10m,30m,1h,6h,12h,1d,7d,14d,30d',
    refresh_on_load: false,
    type: 'interval' } ]
[Mon Oct 19 2015 21:02:10 GMT+0200 (CEST)] ERROR TypeError: Cannot read property 'text' of undefined
  at /home/admin/hubot-customer/node_modules/hubot-grafana/src/grafana.coffee:113:11, <js>:82:65
  at /home/admin/hubot-customer/node_modules/hubot-grafana/src/grafana.coffee:202:14, <js>:178:16
  at IncomingMessage.<anonymous> (/home/admin/hubot-customer/node_modules/hubot/node_modules/scoped-http-client/src/index.js:95:22)
  at emitNone (events.js:72:20)
  at IncomingMessage.emit (events.js:166:7)
  at endReadableNT (_stream_readable.js:903:12)
  at doNTCallback2 (node.js:439:9)
  at process._tickCallback (node.js:353:17)

@Tenzer
Copy link
Collaborator

Tenzer commented Oct 19, 2015

Actually, it's template.current which is undefined ("Cannot read property 'text' of undefined"). I'm not totally sure what goes on in that part of the code (I don't use templating myself), but perhaps we just need to check if template.current is set?

I'm not really sure what we are expecting to get from template.current.text. If we absolutely need that to be set, I guess the best way is to simply skip the items in the array which doesn't have template.current set?

@stephenyeargin stephenyeargin self-assigned this Oct 24, 2015
@stephenyeargin
Copy link
Owner

So this is what it looks like on http://play.grafana.org/dashboard/db/issue-2534

[Sun Oct 25 2015 12:35:12 GMT-0500 (CDT)] DEBUG { allFormat: 'glob',
  current: 
   { tags: [],
     text: 'backend_02 + backend_03',
     value: [ 'backend_02', 'backend_03' ] },
  datasource: null,
  includeAll: false,
  multi: true,
  multiFormat: 'glob',
  name: 'servers',
  options: 
   [ { selected: false, text: 'backend_01', value: 'backend_01' },
     { selected: true, text: 'backend_02', value: 'backend_02' },
     { selected: true, text: 'backend_03', value: 'backend_03' },
     { text: 'backend_04', value: 'backend_04' } ],
  query: 'apps.backend.*',
  refresh_on_load: false,
  type: 'query' }

This will probably need revisiting as more folks use it, but for the time being, I'm going to skip assigning template variables if a current property is not set. Worst case it doesn't format the graph titles with template variables interpolated.

stephenyeargin added a commit that referenced this issue Oct 25, 2015
Fixes #19

Apparently this is not set on every returned value of `dashboard.template.list`, so we shouldn't depend on it when building the string iteroplation array. Skip if not set.
@stephenyeargin
Copy link
Owner

@Seraf Check out v1.4.1 and see if that squares it away for you.

@Seraf
Copy link
Author

Seraf commented Oct 25, 2015

@stephenyeargin I'm not very comfortable with nodejs, not very sure if I have correctly installed it.

I unzipped the zip release into my node_modules directory in /home/admin/hubot where I setup the app. It was missing knox, so I went into the hubot-grafana modules and did a npm install. Then the bot was able to start.

When I try the command I have a :

[Sun Oct 25 2015 20:05:43 GMT+0100 (CET)] ERROR ReferenceError: next is not defined
  at /home/admin/hubot/node_modules/hubot-grafana/src/grafana.coffee:114:11, <js>:84:15
  at /home/admin/hubot/node_modules/hubot-grafana/src/grafana.coffee:204:14, <js>:182:16
  at IncomingMessage.<anonymous> (/home/admin/hubot/node_modules/hubot/node_modules/scoped-http-client/src/index.js:95:22)
  at emitNone (events.js:72:20)
  at IncomingMessage.emit (events.js:166:7)
  at endReadableNT (_stream_readable.js:903:12)
  at doNTCallback2 (node.js:439:9)
  at process._tickCallback (node.js:353:17)

@stephenyeargin
Copy link
Owner

I may have Ruby'd when I should have JavaScript'd

@stephenyeargin
Copy link
Owner

Try v1.4.2 ... Switched out next for continue, which looks to be correct. Apparently my test case was not as specific as I'd thought.

@Seraf
Copy link
Author

Seraf commented Oct 26, 2015

@stephenyeargin thanks, the 1.4.2 fix my problem, everything works as expected now :) 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants