Generate PDF url broken in 5.4?


I made s chart and want to use the pdf url to download a pdf of the chart. But it gives an error. Says method not allowed. Is this broke?

Also how come we cannot get url to image of the chart to embed elsewhere? Seems useful.

The generation URL used to be a synchronous request that would wait and return the PDF. But that changed (somewhere around 5.4) to be an asynchronous request that returns the id of the report to get.

I have some notes that show this example (notice the required -H "kbn-xsrf: reporting" header).

curl -XPOST -k -u elastic:changeit -H "kbn-xsrf: reporting" 'https://localhost:5601/api/reporting/generate/dashboard/41585f30-2e88-11e7-ab33-956973f3c5b8?_g=(refreshInterval:(display:Off,pause:!f,value:0),time:(from:now-15m,mode:quick,to:now))&_a=(filters:!(),options:(darkTheme:!f),panels:!((col:4,id:Web-transactions,panelIndex:1,row:1,size_x:9,size_y:4,type:visualization),(col:1,id:HTTP-error-codes,panelIndex:2,row:8,size_x:6,size_y:3,type:visualization),(col:7,id:HTTP-error-codes-evolution,panelIndex:3,row:8,size_x:6,size_y:3,type:visualization),(col:1,id:Navigation,panelIndex:4,row:1,size_x:3,size_y:4,type:visualization),(col:1,id:Total-number-of-HTTP-transactions,panelIndex:5,row:5,size_x:3,size_y:3,type:visualization),(col:4,id:HTTP-codes-for-the-top-queries,panelIndex:6,row:5,size_x:9,size_y:3,type:visualization),(col:1,id:Top-10-HTTP-requests,panelIndex:7,row:11,size_x:12,size_y:5,type:visualization)),query:(query_string:(analyze_wildcard:!t,query:%27*%27)),timeRestore:!f,title:%27Packetbeat+HTTP+1%27,uiState:(P-7:(vis:(params:(sort:(columnIndex:!n,direction:!n))))),viewMode:view)'

The response includes the api/reporting/jobs/download url to use to get the PDF like;

curl -k -u elastic:changeit 'https://localhost:5601/api/reporting/jobs/download/j26bv6ud01jx8f5fe5fnexbv'

Does that help? Oh, and I think this means you probably can't embed it like you wanted?
The closest thing would be to use the sharing feature to get a link to embed instead of embedding a PDF.


Thanks. This is a difficult use case to understand. The real need we have is to obtain an image of a chart or PDF, in a web friendly way. From either an email or browser, on-demand. This is web design. Since we can already share a chart in real-time, I would think simply exposing an image or PDF render in same fashion is achievable.

But what Kibana implements now requires some kind of middleware to reconcile these web artifacts adding significant complexity that, in our case, is not worth it. We just stick to embedded live widget.

You can always use your browser (I used Chrome) to Save as PDF. Does that help?

No. Because we want to embed the chart image in an email. Where it can just be seen. Having users follow a link and save a bunch of redundant PDF files doesn't make a ton of sense. We want to build automated systems here.

For us, the use case of saving a PDF manually and then sending it out to interested parties doesnt achieve easy automation.

In same fashion that you can share an embedded link to the widget. Exposing a PNG or PDF of it solves the problem. But it has to be synchronous to be of any value (like any URL is). Otherwise it requires workflow logic which introduces significant architecture adjustments for us.

Would you mind describing the complete workflow you'd like? Maybe there's something possible to get what you need or maybe we can get an enhancement request filed for it.

I just chatted with a developer that says you can still use the "legacy" route to generate the PDF which would be a synchronous call (click the link and you get the PDF as the response). Does that solve your need? If so, I'll help you with that.

I think it's as simple as adding &sync to the end of the PDF generation url. But you must you POST and the header as described above.

Just keep in mind that generating the PDF for a large dashboard containing many visualizations could take some time and even cause a timeout (that's why Kibana was changed to do it asynchronously).

UPDATE: This &sync functionality is actually deprecated in 5.5 and won't be available in 6.0. So if you're embedding a link in another web page, in 6.x you would have to wrap the clicking of the link in a javascript method that polls for the completed PDF and returns it.

1 Like

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