Automatically obtain PDF Generation URL for use in Watcher (7.7)

Given a working Dashboard in Kibana 7.7 where we're able to Share > PDF Reports > Generate PDF, we'd like to automate the regular generation of these reports.

We've manually created a Watcher job following the Kibana docs, with a webhook action to call the POST URL in Kibana from Elasticsearch (where Watcher runs). The generated reports can later be downloaded from Elasticsearch, which is great.

What we'd like to do is automate the creation of this Watcher job, e.g. when (re)deploying our setup into an environment. The Elasticsearch Watcher APIs will allow us to do this, but we need to somehow get the POST URL from Kibana, but there doesn't appear to be a Kibana API to easily achieve this.

I've taken a look at using a "template" URL and trying to GET saved_object (dashboard), but don't see an easy way of reliably building the required URL.

Does such a(n undocumented) way of getting the POST URL exist? If not, is there a feature request for this in the pipeline (or should one be created)?

Hi Chris,

I agree we need a way to do this automatically :slight_smile:

You can hack it a bit though. If you take a look at the jobParams= query parameter, you'll notice that it is URI encoded. You can use the decodeURIComponent function available in JavaScript to "decipher" this a bit.

For instance, given this POST URL:

I can decode the jobParams string and find that it reads as:

(browserTimezone:America/Chicago,layout:(dimensions:(height:1884,width:1733),id:preserve_layout),objectType:dashboard,relativeUrls:!('/app/kibana#/dashboard/edf84fe0-e1a0-11e7-b6d5-4dc382ef7f5b_g=(filters:!!(),refreshInterval:(pause:!!f,value:900000),time:(from:now-7d,to:now))'),title:'[Logs] Web Traffic')

Using this you may be able to modify the bits you need to point to the correct dashboard. The majority of this data comes straight from the Dashboard's URL. I don't have any more detailed guidance than that, but you maybe able to modify the necessary bits and run it again through encodeURIComponent to get the desired result.

Yeah, thanks.

I'd been looking at that as a possible way forward although it seemed like there were subtle differences between the two URLs that I'd need to try and cater for in creating the generation url. I'll take a closer look and see whether I can get something working without too much faff.

Worth a ticket being raised to request this as a feature in an upcoming release?

Certainly. We are actively improving our reporting capabilities and hearing about different use cases is helpful. You can use this link to create a feature request in Github. created, thanks.

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