Automating Report Generation
editAutomating Report Generation
editYou can automatically generate reports with Watcher, or by submitting HTTP POST requests from a script.
To automatically generate reports with a watch, you need to configure Watcher to trust the Kibana server’s certificate. For more information, see Securing Reporting.
The interval between report requests must be longer than the time it takes to generate the reports—otherwise, the report queue can back up. To avoid this, increase the time between report requests.
By default, report generation times out if the report cannot be generated
within two minutes. If you are generating reports that contain many complex
visualizations or your machine is slow or under constant heavy load, it
might take longer than two minutes to generate a report. You can increase
the timeout by setting xpack.reporting.queue.timeout
in kibana.yml
.
To get the URL for triggering a report generation during a given time period:
- Load the saved object.
- Use the timepicker to specify a relative or absolute time period.
- Click Share in the Kibana toolbar.
- Select PDF Reports.
- Click Copy POST URL.
The response from this request with be JSON, and will contain a path
property
with a URL to use to download the generated report. When requesting that path,
you will get a 503 response if it’s not completed yet. In this case, retry after the
number of seconds in the Retry-After
header in the response until the PDF is returned.
To configure a watch to email reports, you use the reporting
attachment type
in an email
action. For more information, see
Configuring Email Accounts.
For example, the following watch generates a report that contains the Error Monitoring dashboard and emails the report every hour:
PUT _watcher/watch/error_report { "trigger" : { "schedule": { "interval": "1h" } }, "actions" : { "email_admin" : { "email": { "to": "'Recipient Name <recipient@example.com>'", "subject": "Error Monitoring Report", "attachments" : { "error_report.pdf" : { "reporting" : { "url": "http://0.0.0.0:5601/api/reporting/generate/dashboard/Error-Monitoring?_g=(time:(from:now-1d%2Fd,mode:quick,to:now))", "retries":6, "interval":"1s", "auth":{ "basic":{ "username":"elastic", "password":"changeme" } } } } } } } } }
You must configure at least one email account to enable Watcher to send email. For more information, see Configuring email accounts. |
|
This is an example Generation URL. You can copy and paste the URL for any report from the Kibana UI. |
|
Optional, default is 40 |
|
Optional, default is 15s |
|
Provide user credentials for a user with permission to access Kibana and X-Pack reporting. |
Reporting is integrated with Watcher only as an email attachment type.
The report Generation URL might contain date-math expressions
that cause the watch to fail with a parse_exception
.
Remove curly braces {
}
from date-math expressions and
URL-encode characters to avoid this.
For example: ...(range:(%27@timestamp%27:(gte:now-15m%2Fd,lte:now%2Fd))))...
For more information about configuring watches, see How Watcher works.
For more information about configuring watches, see How Watcher Works.