Hello,
I would like to create a script that would trigger a pdf creation of a dashboard. I understand how to create a pdf and send via a saved search, but I would like to use a script to perform the same function.
I am having a little trouble understanding how the pdf renderer works and cannot find any documentation that would describe how to do this...Does anyone have any ideas?
Regards Vince
This is a useful solution for anyone trying to trigger a Splunk dashboard PDF from a script. The important part is that the _ScheduledView__mypdf saved search contains the PDF and dashboard settings, while the REST API request triggers the saved search.
I would also recommend using a dedicated Splunk user instead of the admin account for automation. This makes the setup safer and avoids problems if the administrator account changes later.
For troubleshooting, check the saved search name, dashboard view, REST endpoint, user permissions, and PDF delivery settings. If the dashboard contains many charts or panels, PDF rendering may also take some extra time.
These Splunk discussions may help with related issues:
https://community.splunk.com/t5/Reporting/bd-p/splunk-reporting
https://community.splunk.com/t5/tag/pdf/tg-p/board-id/splunk-reporting
https://community.splunk.com/t5/Reporting/Trigger-a-PDF-via-the-command-line/m-p/147464
Overall, the scheduled-view plus REST API approach is a simple way to trigger dashboard PDF generation from a shell script or automation workflow.
Hi,
I have exactly same requirement where create a dashboard and schedule PDF delivery for that.
I am new to splunk REST API concepts. Can you please explain the script mentioned here
what is PDF Trigger here? Is it an alert with name whatever_alert?
what is ScheduledView_mypdf, it also looks like an alert ?
Where is whatever_alert used in the script?
!/bin/bash
curl -k -u admin:password https://localhost:8089/servicesNS/admin/search/saved/searches/_ScheduledView__mypdf/dispatch -d trigger_actions=1
How does splunk server know that whatever_alert needs to be called for this ScheduledView_mypdf?
I need to do all these using Splunk Java SDK. Any step by step instruction on how to do this will be appreciated. Thanks in advance!
This works!
[whatever_alert]
action.script = 1
action.script.filename = whatever_pdf_trigger.sh
cron_schedule = */10 * * * *
dispatch.earliest_time = -2m@m
dispatch.latest_time = now
displayview = flashtimeline
enableSched = 1
counttype = number of events
relation = greater than
quantity = 0
search = index=ops | head 2
[_ScheduledView__mypdf]
action.email = 1
action.email.maxtime = 60m
action.email.paperorientation = portrait
action.email.papersize = letter
action.email.pdfview = mypdf
action.email.sendpdf = 1
action.email.to = [email protected]
action.email.ttl = 10
cron_schedule = */5 * * * *
description = scheduled search for view name=mypdf
dispatch.earliest_time = 1
dispatch.latest_time = 2
enableSched = 0
is_visible = 0
search = | noop
!/bin/bash
curl -k -u admin:password https://localhost:8089/servicesNS/admin/search/saved/searches/_ScheduledView__mypdf/dispatch -d trigger_actions=1
Could you share the script ?
If that user expires because they leave the company, then what? Is there a caveat to using admin?
It might be a good idea to use a different user than admin. If you do the url changes to:
https://localhost:8089/servicesNS/my_user/search/saved/searches/_ScheduledView__mypdf/dispatch -d trigger_actions=1
Very nice - this works great.
one more try to see if anyone has any ideas?
Sorry, just to clarify this a bit further, the view I have set up is complex and has a lot of graphs, etc. So it is not something that I can run as a search and then use sendemail. I am wanting to generate the pdf from the html page and then forward this pdf onto an email address, similar to using a scheduled search but I need to be able to trigger it from a script