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>
  • Visualization Reports: /api/reporting/generate/visualization/<visualization-id>
  • Saved Search Reports: /api/reporting/generate/search/<saved-search-id>

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 you get the PDF.

Previously there was a &sync parameter appended to generation URLs which would hold the request open until the document was fully generated. Existing use of the &sync parameter, in Watcher for example, will continue to be supported, but will log a deprecation warning. Support for the &sync parameter will be removed in the next major version.

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))

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 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 _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" : {
            "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.

For more information about configuring watches, see How Watcher Works.