Automatically generate reports
editAutomatically generate reports
editTo automatically generate PDF and CSV reports, generate a POST URL, then submit an HTTP POST
request using Watcher or a script. Alternatively, use Kibana to generate reports on a recurring schedule and share them with a list of emails that you specify.
Create a POST URL
editCreate the POST URL that triggers a report to generate PDF and CSV reports.
PDF or PNG reports
editTo create the POST URL for PDF reports:
- Go to Dashboards, Visualize Library, or Canvas. From the toolbar, do one of the following:
-
Open the dashboard, visualization, or Canvas workpad you want to view as a report.
- If you are using Dashboard or Visualize Library, from the toolbar, click the Export icon, then PDF or PNG. In the export flyout, copy the POST URL.
- If you are using a Canvas workpad, from the toolbar, click Share > PDF Reports, then click Advanced options > Copy POST URL.
CSV reports
editTo create the POST URL for CSV reports:
- Go to Discover.
- Open the saved Discover session you want to share.
- In the toolbar, click the Export icon, then CSV. In the export flyout, copy the POST URL.
Use Watcher
editTo configure a watch to email reports, use the reporting
attachment type in an email
action. For more information, refer to Configuring email accounts.
For example, the following watch generates a PDF report 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": "<KIBANA_HOST>:5601/api/reporting/generate/printablePdfV2?jobParams=...", "retries":40, "interval":"15s", "auth":{ "basic":{ "username":"elastic", "password":"changeme" } } } } } } } } }
Configure at least one email account to enable Watcher to send email. For more information, refer to Configuring email accounts. |
|
An example POST URL. You can copy and paste the URL for any report. |
|
Optional, default is |
|
Optional, default is |
|
User credentials for a user with permission to access Kibana and the reporting features. For more information, refer to Configure 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
. To avoid a failed watch, remove curly braces {
}
from date-math expressions and URL-encode characters.
For example, ...(range:(%27@timestamp%27:(gte:now-15m%2Fd,lte:now%2Fd))))...
For more information about configuring watches, refer to How Watcher works.
Use a script
editTo automatically generate reports from a script, make a request to the POST
URL. The request returns a JSON and contains a path
property with a
URL that you use to download the report. Use the GET
method in the HTTP request to download the report.
To queue CSV report generation using the POST
URL with cURL:
curl \ -XPOST \ -u elastic \ -H 'kbn-xsrf: true' \ '<KIBANA_HOST>:5601/api/reporting/generate/csv?jobParams=...'
The required |
|
The user credentials for a user with permission to access Kibana and reporting features. |
|
The required |
|
The POST URL. You can copy and paste the URL for any report. |
An example response for a successfully queued report:
{ "path": "/api/reporting/jobs/download/jxzaofkc0ykpf4062305t068", "job": { "id": "jxzaofkc0ykpf4062305t068", "index": ".reporting-2018.11.11", "jobtype": "csv", "created_by": "elastic", "payload": ..., "timeout": 120000, "max_attempts": 3 } }
The relative path on the Kibana host for downloading the report. |
|
(Not included in the example) Internal representation of the reporting job, as found in the |
HTTP response codes
editThe response payload of a request to generate a report includes the path to download a report. The API to download a report uses HTTP response codes to give feedback. In automation, this helps external systems track the various possible job states:
-
200
(OK): As expected, Kibana returns200
status in the response for successful requests to queue or download reports.Kibana will send a
200
response status for successfully queuing a Reporting job via the POST URL. This is true even if the job somehow fails later, since report generation happens asynchronously from queuing. -
400
(Bad Request): When sending requests to the POST URL, if you don’t usePOST
as the HTTP method, or if your request is missing thekbn-xsrf
header, Kibana will return a code400
status response for the request. -
503
(Service Unavailable): When using thepath
to request the download, you will get a503
status response if report generation hasn’t completed yet. The response will include aRetry-After
header. You can set the script to wait the number of seconds in theRetry-After
header, and then repeat if needed, until the report is complete. -
500
(Internal Server Error): When using thepath
to request the download, you will get a500
status response if the report isn’t available due to an error when generating the report. More information is available at Management > Kibana > Reporting.
Deprecated report URLs
editIf you experience issues with the deprecated report URLs after you upgrade Kibana, regenerate the POST URL for your reports.
-
Dashboard reports:
/api/reporting/generate/dashboard/<dashboard-id>
-
Visualize Library reports:
/api/reporting/generate/visualization/<visualization-id>
-
Discover reports:
/api/reporting/generate/search/<discover-session-id>
IMPORTANT:
In earlier Kibana versions, you could use the &sync
parameter to append to report URLs that held the request open until the document was fully generated. The &sync
parameter is now unsupported. If you use the &sync
parameter in Watcher, you must update the parameter.
Schedule and share reports
editThis functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.
Save time by setting up a recurring task that automatically generates reports and shares them on a schedule that you choose.
Prerequisites
edit- To generate PDF and PNG reports, your Kibana instance needs a minimum of 2GB of RAM. There is no minimum requirement for CSV reports.
- To use the scheduled reports feature, your role needs access to reporting.
-
(Optional) To view and manage other users' reports and schedules, your role needs
All
privileges for the Manage Scheduled Reports feature. You can set this by configuring your role’s Kibana privileges. If your role doesn’t have the Manage Scheduled Reporting feature privilege, you can only share reports with yourself. -
Sharing reports outside of Kibana requires a default preconfigured email connector.
- Elastic Cloud Hosted or Serverless users: You do not need to set up a default preconfigured email connector. Kibana provides you with a built-in preconfigured email connector that uses the SMTP protocol to send emails. To view it, go to the Connectors page and find the Elastic-Cloud-SMTP connector.
-
Self-managed users: You must set up a default preconfigured email connector to send notifications outside of Kibana. To do this:
-
Open your
kibana.yml
file. -
Add the
xpack.actions.preconfigured
Kibana setting. This setting specifies configuration details for the preconfigured connector that you’re defining. -
Under the
xpack.actions.preconfigured
setting, define the email connector. Refer to Email connectors to learn about requirements for different email services and providers.You must define preconfigured email connector details in the
kibana.yml
file. You cannot create a preconfigured email connector from the Kibana UI. -
Add the
notifications.connectors.default.email
Kibana setting, and provide the name of your email connector. Thenotifications.connectors.default.email
setting specifies the default email connector to use when sending notifications. This is especially useful if you have multiple email connectors and want to set a default one.The following example shows a modified
kibana.yml
file with a preconfigured email connector that’s set as the default connector for email notifications:xpack.actions.preconfigured: my-email: name: preconfigured-email-connector-type actionTypeId: .email config: service: other from: testsender@test.com host: validhostname port: 8080 secure: false hasAuth: true secrets: user: testuser password: passwordkeystorevalue notifications.connectors.default.email: my-email
-
Open your
-
(Optional) To control who can receive email notifications from Kibana, add the
xpack.actions.email.domain_allowlist
setting to yourkibana.yml
file.
Create a schedule
edit- Open the saved Discover session, dashboard, or visualization you want to share.
- Click the Export icon, then Schedule export.
- Enter the requested details, and (optional) enable Print format to generate the report in a printer-friendly format.
-
Set up a schedule for generating the report.
- Date: Choose when to start generating reports.
- Timezone: Specify a timezone for the schedule.
- Repeat: Choose how often you want to generate reports.
-
(Optional) To share generated reports outside of Kibana, enable Send by email and enter a list of email addresses. Recipients will receive emails with the generated reports attached and on the schedule that you specified.
If your role doesn’t have the Manage Scheduled Reporting feature privilege, you can only send reports to yourself.
- Click Schedule exports to save the schedule.
A message appears, indicating that the schedule is available on the Reporting page. From the Reporting page, click on the Schedules tab to view details for the newly-created schedule.
Note that you cannot edit or delete a schedule after you create it. To stop the schedule from running, you must disable it. Disabling a schedule permanently stops it from running. To restart it, you must create a new schedule.
Scheduled reports limitations
editThe feature enables analysis of data in external tools, but it is not intended for bulk export or to backup Elasticsearch data. Issues with report generation and sharing are likely to happen in the following scenarios:
- The limit for email attachments is 10 MB. Kibana might fail to attach reports that are larger than this size.
- Scheduling too many reports at the same time might cause reports to be shared late or at an inconsistent schedule. Kibana Task Manager runs reporting tasks one at a time.
- If your cluster is running many tasks in general, reports may be delayed.
- Scheduling reports of Canvas workpads is not supported since Canvas workpads are in maintenance mode.
- Scheduling CSV reports of Lens visualizations is not supported.