X-pack :-Report : PDF generated report in the mail attached is getting corrupted

As i am trying to generate a report dynamically and trigger it on a specified time:
The pdf report is getting generated dynamically based on the given URL and sending it as an attachment successfully but the problem here is when i try to open the attachment i was encountered with the following error:

ERROR : "Could not open dynamic_report.pdf, because it is either not supported file type or the file has been damaged (for example it was sent as an email attachment and wansn't correctly decoded)"

The code snippet is as shown below:

  "actions": {
    "send_email": {
      "email": {
          "to": [
          "kiran.ila@acc.com"
        ],
        "subject": "Watcher Report on closed tickets",
        "body": {
          "text": " Watcher \"{{ctx.watch_id}}\" Encountered {{ctx.payload.hits.total}} log entries, see attached data"
        },
        "attachments": {
          "dynamic_report.pdf": {
            "http": {
                "content_type": "application/pdf",
              "request": {
                "method": "post",
                "path": "http://localhost:5601/api/reporting/generate/dashboard/49c9f2a0-4602-11e7-bfa0-bde6558f0f7d?_g=()&_a=(filters:!(),viewMode:view)",
                "params": {},
                "headers": {
                    "kbn-xsrf": "reporting"
                },
                "auth": {
                  "basic": {
                    "username": "elastic",
                    "password": "****"
                  }
                },
                "read_timeout_millis": 300000
              }
              
            }
          }
        },
        "priority": "high"
        
      }
    }
  }
}

OBSERVASTION: The above code when i saved and reopened it was automatically transformed as shown below:

  "actions": {
    "send_email": {
      "email": {
        "profile": "standard",
        "attachments": {
          "dynamic_report.pdf": {
            "http": {
              "request": {
                "scheme": "http",
                "host": "localhost",
                "port": 5601,
                "method": "post",
                "path": "/api/reporting/generate/dashboard/49c9f2a0-4602-11e7-bfa0-bde6558f0f7d",
                "params": {
                  "_g": "()",
                  "_a": "(filters:!(),options:(darkTheme:!f),panels:!((col:1,id:f3848770-4601-11e7-bfa0-bde6558f0f7d,panelIndex:1,row:25,size_x:6,size_y:4,type:visualization),(col:1,id:'56aecc90-4600-11e7-bfa0-bde6558f0f7d',panelIndex:2,row:17,sizeype:visualization),(col:1,id:'383872d0-45ff-11e7-bfa0-bde6558f0f7d',panelIndex,viewMode:view)"
                },
                "headers": {
                  "kbn-xsrf": "reporting"
                },
                "auth": {
                  "basic": {
                    "username": "elastic",
                    "password": "****"
                  }
                },
                "read_timeout_millis": 300000
              },
              "content_type": "application/pdf"
            }
          }
        },
        "to": [
          "kiran.ila@acc.com"
        ],
        "subject": "Watcher Report on closed tickets",
        "body": {
          "text": " Watcher \"{{ctx.watch_id}}\" Encountered {{ctx.payload.hits.total}} log entries, see attached data"
        }
      }
    }
  }

Note : please dont consider the "path" and "params" as i have modified them.

Not sure why the code is being transformed as above
One More OBSERVATION : when i tried generating the PDF by navigating
DashBoards -> KPI Stats -> Reporting -> Generate Printable PDF
name of the Dashboard.
Now the generated report is found in Management->Reporting
But all the time the report generating is failing not sure why so like that, (not sure where the logs will be found for this issue)

when clicked on red icon the following error is shown:

There was an error generating your report for the "Ticket Analysis" dashboard: Max attempts reached (3)

Could you please help me out in resolving this issue.. Thanks in advance.

That error may also be why the files you get from Watcher aren't valid PDF files. If you look at the content of the attached files, I suspect they will just contain error text.

Usually when you see that error message, it means that the Dashboard didn't finish rendering in time for Reporting to grab a screenshot of the visualizations on it. This could happen due to a number of reasons. In order to track down the actual cause, could you please let us know:

  • The version of Kibana/X-Pack you are using (they will be the same)
  • If you are running Kibana with any custom settings in the kibana.yml file, and if so, what those settings are

Hi Joe,

Thanks for your reply....

Firstly my kibana.yml doesnt have setting except this entry in it:

xpack.watcher.enabled: true

I am not able to open the files as their status is failed.
Is there any possibility that i can increase the rendering time for Dashboard or visualization?
Is there any possibility that i can customize the retry attempts?

Is there any possibility that i can customize the retry attempts?

Unfortunately, there is not a setting for this.

Is there any possibility that i can increase the rendering time for Dashboard or visualization?

You can use xpack.reporting.capture.timeout, the default is 20000 (20 seconds). I can tell you that, based on all my past experience dealing with this problem, increasing that timeout will almost certainly not fix the problem though.

Usually the problem is network related, and caused by a proxy or something in front of Kibana. Based on your watcher formula though, it looks like you're simply running everything on a single machine, so that's probably not the issue. Am I right though, are you simply running Kibana on your machine?

If you are using custom visualizations, and they aren't set up correct, that could also be the cause. And I think we may have shipped a version of Kibana where tilemaps didn't work correctly with Reporting, but any latest patch version released should be functional.

It's tricky to say what the cause might be. If you can tell me the version of Kibana you're running, I can tell you how to get additional logging output though.

Thanks Joe for your reply...

As you said i am running everything on a single machine..
And i am using Kibana 5.4.0 vesion.

1 Like

In 5.4.x, there's a couple ways to get logs.

You can see all of the debugging logs by adding logging.verbose: true to your kibana.yml file. This will show you a ton of information, certainly more than you care about, which will probably make it hard to pick out the information you care about.

You can also specify exactly what kind of logs you want to see in the output. It seems to be undocumented, but it's pretty simple. In this case, you want to see reporting and phantomConsole logs. You can add the following to your kibana.yml file, which should give you this output:

logging.events.logs: ['reporting', 'phantomConsole']

Note that this will stop all of the normal output, including info, warnings, and errors. If you'd like to continue to see that as well, use this:

logging.events.logs: ['info', 'warning', 'error', 'fatal', 'reporting', 'phantomConsole']

Once you've got that set up, restart Kibana to load the new config and manually generate a report, using the UI in visualize or dashboard. Whatever you manually did before is fine. Now if you check the output from the Kibana server, you'll see some reporting and phantom output, including the URLs being requested, any failures in the response, or failures loading the page, etc. This should help determine what is causing the report to error out. If you can't make sense of it, post the output here and I should be able to offer up a solution.

Thanks Joe for your help and detailed explanation.. :slight_smile:

I will try out in my machine and let you know if any issue occurs.
Thanks for your suggestion.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.