Watcher unable to generate PDF report via webhook (7.7.0)

We're trying to setup a Watcher job that will call a Dashboard POST URL to generate a PDF on a regular interval via a webhook. This report is then stored in Elasticsearch and downloadable by support users.

We appear to be fairly close but are receiving the following error when Watcher (from Elasticsearch) calls the generate report API endpoint (in Kibana):

Debug: internal, implementation, error 
    TypeError: Cannot read property 'showLinks' of undefined
    at licensePreRouting (/usr/share/kibana/x-pack/legacy/plugins/reporting/server/routes/lib/reporting_feature_pre_routing.js:27:29)
    at module.exports.internals.Manager.execute (/usr/share/kibana/node_modules/hapi/lib/toolkit.js:35:106)
    at Object.internals.handler (/usr/share/kibana/node_modules/hapi/lib/handler.js:50:48)
    at exports.execute (/usr/share/kibana/node_modules/hapi/lib/handler.js:21:37)
    at process._tickCallback (internal/process/next_tick.js:68:7)

We have simply copied the URL given to us by the Kibana Dashboard (via the Share > PDF > Copy POST URL menu) into the Watcher job spec, added a user auth (who is a member of the reporting_user role and has access to the space in which the dashboard sits with Read access for the Dashboard).

The Watcher webhook event is definitely hitting the Kibana instance and appears to be trying to generate the report, but then fails with the above - confusingly tagged as a Debug statement, but appear to be an error, which is then repeated in the below log message:

{"type":"error","@timestamp":"2020-05-25T13:41:04Z","tags":[],"pid":110,"level":"error","error":{"message":"Cannot read property 'showLinks' of undefined","name":"TypeError","stack":"TypeError: Cannot read property 'showLinks' of undefined\n    at licensePreRouting (/usr/share/kibana/x-pack/legacy/plugins/reporting/server/routes/lib/reporting_feature_pre_routing.js:27:29)\n    at module.exports.internals.Manager.execute (/usr/share/kibana/node_modules/hapi/lib/toolkit.js:35:106)\n    at Object.internals.handler (/usr/share/kibana/node_modules/hapi/lib/handler.js:50:48)\n    at exports.execute (/usr/share/kibana/node_modules/hapi/lib/handler.js:21:37)\n    at process._tickCallback (internal/process/next_tick.js:68:7)"},"url":{"protocol":null,"slashes":null,"auth":null,"host":null,"port":null,"hostname":null,"hash":null,"search":null,"query":{},"pathname":"/api/reporting/generate/printablePdf%3FjobParams=(browserTimezone:Europe%2FLondon,layout:(id:print),objectType:dashboard,relativeUrls:!('%2Fs%2Fmi%2Fapp%2Fkibana%23%2Fdashboard%2F40c99430-3a3d-11ea-a0d3-837b95f9b7e4%3F_a=(description:!'!',filters:!!(),fullScreenMode:!!f,options:(hidePanelTitles:!!f,useMargins:!!t),panels:!!((embeddableConfig:(params:(sort:(columnIndex:4,direction:asc)),vis:(params:(sort:(columnIndex:4,direction:desc)))),gridData:(h:57,i:e8783343-e1a9-4864-a0ef-1397f735238b,w:24,x:0,y:0),id:de97ff90-3a41-11ea-a0d3-837b95f9b7e4,panelIndex:e8783343-e1a9-4864-a0ef-1397f735238b,type:visualization,version:!'7.7.0!'),(embeddableConfig:(legendOpen:!!t,vis:(legendOpen:!!f)),gridData:(h:16,i:f4af2d34-8216-4587-8e12-41c27ee837d9,w:23,x:24,y:0),id:!'7ffb7cc0-3a3f-11ea-a8d2-6db16e900dd7!',panelIndex:f4af2d34-8216-4587-8e12-41c27ee837d9,type:visualization,version:!'7.7.0!')),query:(language:kuery,query:!'!'),timeRestore:!!t,title:!'Upload%2520History!',viewMode:view)&_g=(filters:!!(),refreshInterval:(pause:!!t,value:0),time:(from:now-1w,to:now%252Fw))'),title:'Upload%20History')","path":"/api/reporting/generate/printablePdf%3FjobParams=(browserTimezone:Europe%2FLondon,layout:(id:print),objectType:dashboard,relativeUrls:!('%2Fs%2Fmi%2Fapp%2Fkibana%23%2Fdashboard%2F40c99430-3a3d-11ea-a0d3-837b95f9b7e4%3F_a=(description:!'!',filters:!!(),fullScreenMode:!!f,options:(hidePanelTitles:!!f,useMargins:!!t),panels:!!((embeddableConfig:(params:(sort:(columnIndex:4,direction:asc)),vis:(params:(sort:(columnIndex:4,direction:desc)))),gridData:(h:57,i:e8783343-e1a9-4864-a0ef-1397f735238b,w:24,x:0,y:0),id:de97ff90-3a41-11ea-a0d3-837b95f9b7e4,panelIndex:e8783343-e1a9-4864-a0ef-1397f735238b,type:visualization,version:!'7.7.0!'),(embeddableConfig:(legendOpen:!!t,vis:(legendOpen:!!f)),gridData:(h:16,i:f4af2d34-8216-4587-8e12-41c27ee837d9,w:23,x:24,y:0),id:!'7ffb7cc0-3a3f-11ea-a8d2-6db16e900dd7!',panelIndex:f4af2d34-8216-4587-8e12-41c27ee837d9,type:visualization,version:!'7.7.0!')),query:(language:kuery,query:!'!'),timeRestore:!!t,title:!'Upload%2520History!',viewMode:view)&_g=(filters:!!(),refreshInterval:(pause:!!t,value:0),time:(from:now-1w,to:now%252Fw))'),title:'Upload%20History')","href":"/api/reporting/generate/printablePdf%3FjobParams=(browserTimezone:Europe%2FLondon,layout:(id:print),objectType:dashboard,relativeUrls:!('%2Fs%2Fmi%2Fapp%2Fkibana%23%2Fdashboard%2F40c99430-3a3d-11ea-a0d3-837b95f9b7e4%3F_a=(description:!'!',filters:!!(),fullScreenMode:!!f,options:(hidePanelTitles:!!f,useMargins:!!t),panels:!!((embeddableConfig:(params:(sort:(columnIndex:4,direction:asc)),vis:(params:(sort:(columnIndex:4,direction:desc)))),gridData:(h:57,i:e8783343-e1a9-4864-a0ef-1397f735238b,w:24,x:0,y:0),id:de97ff90-3a41-11ea-a0d3-837b95f9b7e4,panelIndex:e8783343-e1a9-4864-a0ef-1397f735238b,type:visualization,version:!'7.7.0!'),(embeddableConfig:(legendOpen:!!t,vis:(legendOpen:!!f)),gridData:(h:16,i:f4af2d34-8216-4587-8e12-41c27ee837d9,w:23,x:24,y:0),id:!'7ffb7cc0-3a3f-11ea-a8d2-6db16e900dd7!',panelIndex:f4af2d34-8216-4587-8e12-41c27ee837d9,type:visualization,version:!'7.7.0!')),query:(language:kuery,query:!'!'),timeRestore:!!t,title:!'Upload%2520History!',viewMode:view)&_g=(filters:!!(),refreshInterval:(pause:!!t,value:0),time:(from:now-1w,to:now%252Fw))'),title:'Upload%20History')"},"message":"Cannot read property 'showLinks' of undefined"}

We've tried (temporarily) granting the user configured in the Watcher job the superuser role, all cluster permissions and also all access to all spaces... but that didn't seem to make any difference - the job keeps failing and this error keeps getting spat into the logs.

Any help, greatly appreciated.

If it makes any difference (but I'd hope it wouldn't), this is with a Trial x-pack licence on a dev instance.

Just tried using the same generate report URL from the Elasticsearch host (container) command line with curl and it seems to have worked fine. So, basically, it seems the issue lies with Watcher and presumably how it's interpreting the wekbook's path parameter - pasting the dashboard POST URL in there hasn't worked.

There are no "date math" curly braces to be replaced, which is the only thing I see in the docs about being wary of, are there any other considerations to bear in mind when configuring the Watcher webhook action's path?

(Side note: host and port are mandatory, the "shortcut" url parameter doesn't appear to work, or at least doesn't if you don't separately specify the first two, which means the third is effectively pointless)

So, working now... turns out my "aside" note above was actually relevant - trying the url parameter instead caused the path and separate params fields to be set and now the job is working (previously, we had the full URI path and query string in path, which apparently it doesn't like although I didn't understand that form the watcher docs).

Frustrating and a bad Kibana exception/log, with nothing apparently evident from the Watcher side... but ultimately this was "user error".

Hi @Chris_Samo!

I made an issue inside of Kibana of your experience and assigned it to the appropriate team to improve the flow of this. Thanks for putting in the legwork to resolve it on your side — hopefully we can improve it for others in the future!

Thanks, that's great (always nice to have upgrade user experience, of course).

I also subsequently realised I'd be better using the input of the Watcher to perform the request, then simply log as an action (including some of the response fields from the input request). However, the same comments still apply as the input and action.webhook (understandably) appear to use the same setups.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.