You get a report! You get a report!

We recently released the first version of Reporting for Kibana which gives users the ability to generate a PDF report from saved Kibana dashboards. By leveraging Watcher’s email action, you can send PDF reports regularly, or only when certain events have occurred.

In this blog post, I will demonstrate the power of Reporting and Watcher integration and how we are dogfooding this in house. For our example use case, we are sending bi-weekly PDF reports to our systems team manager if there are any helpdesk tickets filed by internal employees mentioning a specific keyword.

To get up and running quickly, I have set up an instance on Elastic Cloud because it is so easy to get Elasticsearch (with authentication via Shield) and Kibana running on the latest and greatest versions.

The following example below was created against ES 2.4.0 with Kibana 4.6.1 (when Reporting was originally released). There have been changes in Cloud and Reporting since then. I have added notes in the sections below related to the changes in our products since the original release.

Step 1: Populate the Data

First step is simply to populate Elasticsearch with the data you are reporting against.

We track helpdesk tickets internally using Salesforce’s Service Cloud. In this case, I have written a custom Logstash salesforce plugin using the restforce ruby gem to join object data related to posts, emails and chatter comments from various objects so we can get tickets with the full feed history intact.

Step 2: Install the Reporting Plugin

(Starting in 5.0+, Reporting is now installed with X-Pack on Elastic Cloud. It is no longer necessary to install the Reporting plugin separately).

Reporting is built on top of Kibana, so you will have to set up Kibana and install the Reporting plugin. If you are running on Elastic Cloud, the Reporting plugin is already installed for you when you enable Kibana :)

Step 3: Secure Your Data

Because the data for my use case can potentially be sensitive, I have enabled Shield in my Elastic Cloud instance (“configure Shield”) for authentication. From the Elastic Cloud instance, simply click on the link and then configure the users and roles accordingly.

Note: When installing Kibana in your local environment and enabling security via Shield, keep in mind that Reporting on 2.4 requires the Kibana Shield plugin, and the Kibana Shield plugin in turn requires SSL to be enabled in Kibana. Starting in 5.0+, we no longer require SSL to be enabled in Kibana to use the Kibana Shield plugin (certainly, you may still want to enable SSL for production deployments). Since I am running on Elastic Cloud, SSL is already enabled by default. Yay!

Step 4: Create a Dashboard and View the Report

(For 5.0+, refer to the Reporting documentation for the latest screens and instructions).

Currently, you can only generate a PDF report against a dashboard if the dashboard is an existing/saved object in Kibana.

Once you have created the desired dashboard, click on the “Generate Report” icon (rightmost icon). This will give you a button to generate a Printable PDF report. Clicking on the button will issue a one-time reporting request to the reporting queue.

When the report is ready, you can locate the report in the list of generated reports from Settings > Reporting and download it using the corresponding action icon.

Step 5: Create a Watch to Send the Report

(On 5.0+, Watcher comes packaged with X-pack which is automatically installed on Elastic Cloud. In the above example, it uses the "http" attachment type of the email action which applies to Reporting 4.6 and 5.0. Starting in 5.1+, we now have a specialized "reporting" attachment type specifically for integration between Alerting/Watcher and Reporting. Refer to Reporting documentation for detailed steps.)

Follow the Watcher installation steps to install the Watcher plugin. Since I am using an Elastic Cloud instance, it’s a simple check of the watcher option under the Plugins section and it will install it for you!

Once Watcher is installed and the Watcher service is running, create the watch using the Sense editor or curl equivalent, etc.. If you are running on the Elastic Cloud, Sense editor is pre-installed with Kibana. Watcher + Reporting integration uses Watcher’s email action with attachment capability to trigger report generation and subsequently send the resulting PDF file to the recipients specified.

Before creating the watch, configure a valid smtp server for Watcher to use for sending emails. On Elastic Cloud, you do not have to set up a smtp server and will use the one provided by the Cloud environment (however, remember to whitelist the email addresses for the recipients of your reports).

Use case: Our systems manager has been receiving reports that customers have trouble attaching files to Salesforce Service Cloud support cases. He would like to get a bi-weekly analytics report over 6 months of data on tickets filed against the Service Cloud (our support system) only if there are tickets created related to attachments within the past 2 weeks.

The watch below queries the helpdesk ticket data to see if there are any tickets filed against the support system by internal employees within the past 2 weeks, and if these tickets mention attachments in their feeds (which can be posts, emails, or comments on either). If so, the watch will fire and request the saved dashboard to be generated as a PDF report to be sent to the systems manager.

The request.url string in the watch’s email action is copied from the Generation URL entry from above (screenshot in Step 4) which will be used by Watcher to generate the report on the fly. Currently, report generation is synchronous, which means that it is important to set the request.read_timeout to a timeout that is longer than the time it takes to generate the report. Otherwise, Watcher tasks can start to queue up.

For more detailed explanation of the other settings in the email action, refer to the Reporting documentation.

Step 6: Check Out the Report

Here is the resulting Watcher alert email sent by Elastic Cloud with the PDF report: