Reporting

Scheduled PDF Delivery to file or folder not via email

Path Finder

Hi,

I've got some saved searches scheduled to output CSV files using the outputcsv command which works well. From there I run a script to upload the CSV file to an SFTP server.

I'd like to do something similar with the PDF output from a Dashboard. I have Scheduled PDF Delivery via email but I'm wondering if there is a way to get the PDF output to a file rather than sent via email?

Thanks!

Tags (1)

Path Finder

I couldn't find any answers either, just dead ends. I got a big hammer and crammed this into the pdf generator script at /opt/splunk/etc/system/bin/pdfgen_endpoint.py (5.0.7)
I'm sure this could be embellished to generate unique filenames, trigger some process, etc., but this was more of a proof-of-concept for me.

def _respond(self):
    # save and write out the file
    try:
        pdfsave = open('/some/path/to/myreport.pdf', 'w')
        pdfsave.write(self._pdfBuffer.getvalue())
        pdfsave.close()
        self.response.write(self_pdfBuffer.getvalue())
        ...

I added the three "pdfsave" lines, everything else is original script.

also, I would not recommend doing it how I did it unless you're desperate as it probably won't survive an upgrade, and may catch fire if taunted. however, it shows that splunk has the pdf file in an object just waiting to do all kinds of exciting things with. somebody who actually knew python could probably spend a couple hours and add some pretty useful features, imo.

Path Finder

Nice work! Thanks for the tip.