Issue with sending email with pdf report attachments

I'm experiencing an issue with x-pack 5.0.0 alpha 3. I've set up an email action in XPack Watcher to send an email with a PDF attachment of a report as follows:

"attachments": {
          "my_report.pdf": {
            "http": {
              "content_type": "application/pdf",
              "request": {
                "url": "http://localhost:5601/reporting/dashboard/Dashboard?_g"
              }
            }
          },
          "data.yml": {
            "data": {
              "format": "yaml"
            }
          }

"Dashboard" is the id of my dashboard object.

I get the following error message when I check the status of the watch:
"actions": [
{
"id": "send_email",
"type": "email",
"status": "failure",
"reason": "Unable to get attachment of type [http] with id [my_report.pdf] in watch [scorecard_4] aborting watch execution"
}
]

I get a 404 error if I try to access the URL http://hostname:5601/reporting/dashboard/Dashboard?_g

I've tried specifying the time parameters to the URL and I still see the same issues.

Has anyone encountered this before? Any advice or help will be much appreciated.

Thanks

After installing Xpack 5.0.0 alpha4, I updated the "url" field of the request object to "http://localhost:5601/api/reporting/generate/dashboard/New-Dashboard". This queues up the report to be executed as a background process.

Can I attach the generated report to the email as part of the Watcher email action? - Is it possible to query for the URL of the the generated PDF?

Thanks,
Vinayak

1 Like

Same here. I wonder if it is possible to generate & attach report to email action.

I noticed that the response to reporting/generate contains an id which is the reporting job id. The job id can then be concatenated to http://localhost:5601/api/reporting/jobs/download/ to form a url to download the report.

Suppose the id is iqjdo57d0726f7fb244dxvgp, the url will be http://localhost:5601/api/reporting/jobs/download/iqjdo57d0726f7fb244dxvgp. This works fine if I open this link in any browser but when I try to attach it in the email action as the url for the request it corrupts pdf...

I think that the download from reporting/jobs/download fails during email action because of authentication. Disabling X-Pack security fixed the issue.

I will try to modify the request in the email action to contain auth (Authentication related HTTP headers. Currently, only basic authentication is supported.)

Hey,

right now, there is no synchronous downloading of that PDF, you can just trigger its creation. This will come very soon though, so that watcher will be able to download the PDF directly and attach it to an email.

--Alex

Thank you for your quick response. One question though (actually two) - any chance that soon is 5 GA release?

The second question - is it possible to download that PDF when Security (Shield) enabled? When Security is off, I am able to specify the report's url in the email action in http in request and everything works like a charm. When Security is on it doesn't work. I tried adding basic authentication by adding the auth to the request (similar to WebHook examples) but it didn't help either.

Thank you!

@spinscale?

+1 @spinscale please reply if this feature will be made available.

Hey,

there will be beta releases before GA, so this will take some more time. And yes, it will be possible to download PDFs with security enabled. All we need is the ability to download the PDF in sync from Kibana, which will be released with the next test version of the Elastic Stack.

--Alex

Thanks!

Thank you