# Mailing dashborad as PDF using Watcher

**URL:** <https://discuss.elastic.co/t/mailing-dashborad-as-pdf-using-watcher/372359>\
**Category:** Elasticsearch\
**Created:** [December 24, 2024, 3:19pm UTC](https://discuss.elastic.co/t/mailing-dashborad-as-pdf-using-watcher/372359 "2024-12-24T15:19:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![zaeemmasood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zaeemmasood/32/102383_2.png) [@zaeemmasood](https://discuss.elastic.co/u/zaeemmasood)\
**Post date:** [December 24, 2024, 3:19pm UTC](https://discuss.elastic.co/t/mailing-dashborad-as-pdf-using-watcher/372359/1 "2024-12-24T15:19:37Z")

</div>

Hi All,

I created a dashboard in Kibana and trying to set up a watcher that should send the dashboard as PDF to an email address periodically.

My watcher json is as below:

```auto
{
  "trigger": {
    "schedule": {
      "cron": "0 0 12 * * ?"
    }
  },
  "input": {
    "none": {}
  },
  "condition": {
    "always": {}
  },
  "actions": {
    "email_report": {
      "email": {
        "profile": "standard",
        "attachments": {
          "dashboard_report.pdf": {
            "reporting": {
              "url": "https://abc.cde.com:5606/tvelk/api/reporting/generate/printablePdfV2?jobParams=%28browserTimezone%3AAmerica%2FNew_York%2Clayout%3A%28dimensions%3A%28height%3A847.9861450195312%2Cwidth%3A2114.444580078125%29%2Cid%3Apreserve_layout%29%2ClocatorParams%3A%21%28%28id%3ADASHBOARD_APP_LOCATOR%2Cparams%3A%28dashboardId%3A%2791526f50-bd8a-11ef-bc85-d5d6dd51779a%27%2CpreserveSavedFilters%3A%21t%2CtimeRange%3A%28from%3Anow-7d%2Fd%2Cto%3Anow%29%2CuseHash%3A%21f%2CviewMode%3Aview%29%29%29%2CobjectType%3Adashboard%2Ctitle%3A%27Audit%20Dashboard%27%2Cversion%3A%278.7.0%27%29"
            }
          }
        },
        "to": [
          "xyz.abc@efg.com"
        ],
        "subject": "Dashboard Report"
      }
    }
  }
}

```

When I try to simulate and run the report I get the following error in elasticsearch log:

```auto
[2024-12-24T09:37:08,078][WARN][o.e.c.s.DiagnosticTrustManager] [abc-dd-efg] failed to establish trust with server at [abc-dd-efg]; the server provided a certificate with subject name [CN=Elastic Certificate Tool Autogenerated CA], fingerprint [7c5674fc342fdfd54d65b7920ace706130841c6d], no keyUsage and no extendedKeyUsage; the certificate is valid between [2023-09-15T00:46:18Z] and [2026-09-14T00:46:18Z] (current time is [2024-12-24T14:37:08.078854884Z], certificate dates are valid); the session uses cipher suite [TLS_AES_256_GCM_SHA384] and protocol [TLSv1.3]; the certificate does not have any subject alternative names; the certificate is self-issued; the [CN=Elastic Certificate Tool Autogenerated CA] certificate is not trusted in this ssl context ([(shared) (with trust configuration: JDK-trusted-certs)])

```

I am using self-signed certs in my setup. I tried to disable ssl verification to false in Kibana as follows but it still did not work:

```auto
# To disregard the validity of SSL certificates, change this setting's value to 'none'.
elasticsearch.ssl.verificationMode: none

```

Can a workaround please be suggested?

We have a platinum license on ELK stack 8.7

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [December 24, 2024, 6:18pm UTC](https://discuss.elastic.co/t/mailing-dashborad-as-pdf-using-watcher/372359/2 "2024-12-24T18:18:34Z")

</div>

Hi @zaeemmasood

Since you have platinum you can always open a support ticket.

> [@zaeemmasood](#):
>
> ```auto
> # To disregard the validity of SSL certificates, change this setting's value to 'none'.
> elasticsearch.ssl.verificationMode: none
> 
> ```

That is not the correct setting, that is for Kibana connecting to Elasticsearch.

What you / watcher is doing is Elasticsearch Connecting to Kibana

Please look here

> **[Watcher settings in Elasticsearch | Elasticsearch Guide \[8.17\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/notification-settings.html)**

The settings need to be put in the elasticsearch.yml

You either need to set

`xpack.http.ssl.verification_mode: none`

or provide the path to the CA for the Kibana HTTPS

`xpack.http.ssl.certificate_authorities`

---

<div class="post-metadata">

**Author:** ![zaeemmasood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zaeemmasood/32/102383_2.png) [@zaeemmasood](https://discuss.elastic.co/u/zaeemmasood)\
**Post date:** [December 24, 2024, 6:44pm UTC](https://discuss.elastic.co/t/mailing-dashborad-as-pdf-using-watcher/372359/3 "2024-12-24T18:44:03Z")

</div>

Thanks.

After I set `xpack.http.ssl.verification_mode: none` in elasticsearch.yml the following is seen (401 Unauthorized):

```auto
[2024-12-24T13:41:09,247][ERROR][o.e.x.w.a.e.ExecutableEmailAction] [ab-cde-fgho] failed to execute action [_inlined_/email_report]
org.elasticsearch.ElasticsearchException: Watch[_inlined_] reporting[dashboard_report.pdf] Error response when trying to trigger reporting generation host[ab-cde-fgho], port[5606] method[POST], path[/cvelk/api/reporting/generate/printablePdfV2], response[status=[401], headers=[[kbn-license-sig: [af1aaabe55301e51c0f8dc4d5141236f17597e67383b65be593e02a1f1b31d16]], [content-type: [application/json; charset=utf-8]], [content-security-policy: [script-src 'self'; worker-src blob: 'self'; style-src 'unsafe-inline' 'self']], [content-length: [66]], [kbn-name: [ab-cde-fgho]], [referrer-policy: [no-referrer-when-downgrade]], [connection: [keep-alive]], [cross-origin-opener-policy: [same-origin]], [keep-alive: [timeout=120]], [x-content-type-options: [nosniff]], [date: [Tue, 24 Dec 2024 18:41:09 GMT]], [cache-control: [private, no-cache, no-store, must-revalidate]]], body=[{"statusCode":401,"error":"Unauthorized","message":"Unauthorized"}]]
        at org.elasticsearch.xpack.watcher.notification.email.attachment.ReportingAttachmentParser.requestReportGeneration(ReportingAttachmentParser.java:335) ~[?:?]
        at org.elasticsearch.xpack.watcher.notification.email.attachment.ReportingAttachmentParser.toAttachment(ReportingAttachmentParser.java:191) ~[?:?]
        at org.elasticsearch.xpack.watcher.notification.email.attachment.ReportingAttachmentParser.toAttachment(ReportingAttachmentParser.java:53) ~[?:?]
        at org.elasticsearch.xpack.watcher.actions.email.ExecutableEmailAction.execute(ExecutableEmailAction.java:73) ~[?:?]
        at org.elasticsearch.xpack.core.watcher.actions.ActionWrapper.execute(ActionWrapper.java:175) ~[?:?]
        at org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:560) ~[?:?]
        at org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:342) ~[?:?]
        at org.elasticsearch.xpack.watcher.transport.actions.TransportExecuteWatchAction$1.doRun(TransportExecuteWatchAction.java:193) ~[?:?]
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26) ~[elasticsearch-8.7.0.jar:?]
        at org.elasticsearch.xpack.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:666) ~[?:?]
        at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:891) ~[elasticsearch-8.7.0.jar:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
        at java.lang.Thread.run(Thread.java:1589) ~[?:?]

```

Please guide.

Thanks

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [December 24, 2024, 7:01pm UTC](https://discuss.elastic.co/t/mailing-dashborad-as-pdf-using-watcher/372359/4 "2024-12-24T19:01:34Z")

</div>

Well, now you need to provide credentials to generate the report.... The 401 is not authorized.

Perhaps refer to the documentation which shows an example

> **[Automatically generate reports | Kibana Guide \[8.17\] | Elastic](https://www.elastic.co/guide/en/kibana/current/automating-report-generation.html#use-watcher)**

---

<div class="post-metadata">

**Author:** ![zaeemmasood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zaeemmasood/32/102383_2.png) [@zaeemmasood](https://discuss.elastic.co/u/zaeemmasood)\
**Post date:** [December 25, 2024, 4:48am UTC](https://discuss.elastic.co/t/mailing-dashborad-as-pdf-using-watcher/372359/5 "2024-12-25T04:48:22Z")

</div>

Thanks. I added the following in elasticsearch.yml:

```auto
xpack.notification.email.account:
     outlook_account:
         profile: outlook
         smtp:
             auth: true
             starttls.enable: true
             host: prelay.abc.def.net
             port: 25
             user: aa.bb@tif.com

```

After that I created the following watcher json:

```auto
{
  "trigger": {
    "schedule": {
      "interval": "1h"
    }
  },
  "input": {
    "none": {}
  },
  "condition": {
    "always": {}
  },
  "actions": {
    "email_admin": {
      "email": {
        "profile": "standard",
        "attachments": {
          "dash_report.pdf": {
            "reporting": {
              "url": "https://ab.cdf.eft:5606/tvelk/api/reporting/generate/printablePdfV2?jobParams=%28browserTimezone%3AUS%2FEastern%2Clayout%3A%28dimensions%3A%28height%3A427.98614501953125%2Cwidth%3A2133.33349609375%29%2Cid%3Apreserve_layout%29%2ClocatorParams%3A%21%28%28id%3ADASHBOARD_APP_LOCATOR%2Cparams%3A%28dashboardId%3A%279fcea110-c178-11ef-8072-6915c99bf728%27%2CpreserveSavedFilters%3A%21t%2CtimeRange%3A%28from%3Anow-15m%2Cto%3Anow%29%2CuseHash%3A%21f%2CviewMode%3Aview%29%29%29%2CobjectType%3Adashboard%2Ctitle%3A%27Audit%20test%27%2Cversion%3A%278.7.0%27%29",
              "retries": 40,
              "interval": "15s",
              "auth": {
                "basic": {
                  "username": "kib_admin",
                  "password": "::es_redacted::"
                }
              }
            }
          }
        },
        "to": [
          "'Recipient Name <ee.od@tif.com>'"
        ],
        "subject": "Monthly dashboard Report"
      }
    }
  }
}

```

When I run it now I get the following:

![image](https://us1.discourse-cdn.com/elastic/original/3X/c/c/ccdda4a8c735a3e9ae1132ec065a213b27899fff.png)

Please guide. Note that I have intentionally changed certain parameters (hostname etc) to maintain privacy.

Thanks

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [December 25, 2024, 6:58am UTC](https://discuss.elastic.co/t/mailing-dashborad-as-pdf-using-watcher/372359/6 "2024-12-25T06:58:43Z")

</div>

> [@zaeemmasood](#):
>
> When I run it now I get the following:

> [@zaeemmasood](#):
>
> `"password": "::es_redacted::"`

You have to put in the `password` each time

Even if it takes it once, you need to set it every time

So first time I took your exact json above and changed the password to

` "password": "mypassword"`

I save it .. it works fine...

If then I edit it it comes back with

` "password": "::es_redacted::"`

If you save it like that you will get the error you got above

 ![Screenshot 2024-12-24 at 10.56.38 PM](https://us1.discourse-cdn.com/elastic/original/3X/d/6/d677d82b1c1b1c8b88c17c60ce2bf0bf9763eea0.png)

but if you put in an actual password it will work.

` "password": "mypassword"`

It will then save fine

If you want to simulate you need to put the valid password in, leave it there and then simulate...

---

<div class="post-metadata">

**Author:** ![zaeemmasood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zaeemmasood/32/102383_2.png) [@zaeemmasood](https://discuss.elastic.co/u/zaeemmasood)\
**Post date:** [December 27, 2024, 3:23pm UTC](https://discuss.elastic.co/t/mailing-dashborad-as-pdf-using-watcher/372359/7 "2024-12-27T15:23:52Z")

</div>

Thank you so much!!

It worked.

---

<div class="post-metadata">

**Author:** ![zaeemmasood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zaeemmasood/32/102383_2.png) [@zaeemmasood](https://discuss.elastic.co/u/zaeemmasood)\
**Post date:** [December 28, 2024, 4:08pm UTC](https://discuss.elastic.co/t/mailing-dashborad-as-pdf-using-watcher/372359/8 "2024-12-28T16:08:10Z")

</div>

One more question on the same.

Can I add multiple recipients on the watcher?

I googled and it seems that I have to add another `"email_admin1"` with the same settings.

Thanks

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [December 28, 2024, 4:14pm UTC](https://discuss.elastic.co/t/mailing-dashborad-as-pdf-using-watcher/372359/9 "2024-12-28T16:14:40Z")

</div>

> [@zaeemmasood](#):
>
> ```auto
> "to": [
> "ee.od@tif.com", "otheremail@domain.com" 
> ],
> 
> ```

The `to` takes an array of recipients don't confuse that with the email user you provided to login/authenticate with the email server.

---

<div class="post-metadata">

**Author:** ![zaeemmasood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zaeemmasood/32/102383_2.png) [@zaeemmasood](https://discuss.elastic.co/u/zaeemmasood)\
**Post date:** [December 28, 2024, 4:37pm UTC](https://discuss.elastic.co/t/mailing-dashborad-as-pdf-using-watcher/372359/10 "2024-12-28T16:37:26Z")

</div>

> [@zaeemmasood](#):
>
> ```auto
> "to": [
> "'Recipient Name <ee.od@tif.com>'"
> ],
> 
> ```

Thanks again!
