Automating Report Generationedit

You can automatically generate reports with a watch, 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 30 seconds. If you are generating reports that contain complex visualizations or your machine is slow or under constant heavy load, it might take longer than 30 seconds to generate a report. You can increase the timeout by setting xpack.reporting.queue.timeout in kibana.yml.

You request reports through three X-Pack reporting endpoints:

  • Dashboard Reports: /api/reporting/generate/dashboard/<dashboard-id>&sync
  • Visualization Reports: /api/reporting/generate/visualization/<visualization-id>&sync
  • Saved Search Reports: /api/reporting/generate/search/<saved-search-id>&sync

The &sync parameter is required to retrieve a PDF of the report. If you omit it, X-Pack reporting returns a JSON structure that only contains the report metadata.

To specify the time period you want to include in the report, you use the _g parameter in the request. For example:

http://0.0.0.0:5601/api/reporting/generate/dashboard/error-monitoring?_g=(time:(from:now-1d%2Fd,mode:quick,to:now-1d%2Fd))&sync

You can get the URL for a particular report from Kibana:

  1. Load the saved object.
  2. Click Reporting in the Kibana toolbar.
  3. Copy the displayed Generation URL.

To configure a watch to email reports, you use the http attachment type in an email action.

For example, the following watch generates a report that contains the Error Monitoring dashboard and emails the report every hour:

PUT _xpack/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" : {
          "http" : {
            "content_type" : "application/pdf",
            "request" : {
              "method": "POST", 
              "headers": {
                "kbn-xsrf": "reporting"
              },
              "read_timeout": "300s", 
              "url": "http://0.0.0.0:5601/api/reporting/generate/dashboard/Error-Monitoring?_g=(time:(from:now-1d%2Fd,mode:quick,to:now))&sync" 
            }
          }
        }
      }
    }
  }
 }
}

You must configure at least one email account to enable Watcher to send email.

Requests to the Reporting endpoints must use POST and include the kbn-xsrf header.

Increase the read_timeout to give X-Pack reporting enough time to generate the report.

This is an example Generation URL. You can copy and paste the URL for any report from the Kibana UI.

For more information about configuring watches, see How Watches Work.