Issue with automatic email reporting with Watcher

I am trying to add a custom watcher to generate a PNG dashboard and email to a custom email but I am having issues. When I simulate the watcher, my simulation results error out with email issues. I am using Elastic Cloud:

"error": {
  "root_cause": [
    {
      "type": "messaging_exception",
      "reason": "failed to send email with subject [Error Monitoring Report] via account [work]"
    }
  ],
  "type": "messaging_exception",
  "reason": "failed to send email with subject [Error Monitoring Report] via account [work]",
  "caused_by": {
    "type": "send_failed_exception",
    "reason": "Invalid Addresses",
    "caused_by": {
      "type": "s_m_t_p_address_failed_exception",
      "reason": "554 5.7.1 <some_email@gmail.com>: Recipient address rejected: Access denied\n"
    }
  }
}

Here is my watcher code:

{
  "trigger": {
    "schedule": {
      "interval": "1m"
    }
  },
  "input": {
    "none": {}
  },
  "condition": {
    "always": {}
  },
  "actions": {
    "email_admin": {
      "email": {
        "profile": "standard",
        "attachments": {
          "error_report.pdf": {
            "http": {
              "request": {
                "scheme": "https",
                "host": "host",
                "port": port,
                "method": "post",
                "path": "/api/reporting/generate/png",
                "params": {
                  "jobParams": "params"
                },
                "headers": {
                  "Authorization": "someparam",
                  "kbn-xsrf": "reporting"
                },
                "read_timeout_millis": 300000
              },
              "content_type": "application/pdf"
            }
          }
        },
        "to": [
          "some_email@gmail.com"
        ],
        "subject": "Error Monitoring Report"
      }
    }
  }
}

If possible, the email generated, I would like the PNG image as the body of the message, not the attachment as well. I assumed its because I dont have an email account setup (possible) and I looked at this link: Email action | Elasticsearch Guide [6.6] | Elastic but I cannot find a way to edit the .yml file in elastic cloud.

Thanks all

Hi, here's how to enable alerting emails on Elastic Cloud: https://www.elastic.co/guide/en/cloud/current/ec-watcher.html#ec-watcher-whitelist

Note that the recipient email needs to confirm being added, so I recommend changing some_email@gmail.com to a real email that you own.

I will try that out but then the system wont work for us in how I am trying to use it. We dont want to white-list the user. Here is the use-case:

Create generic dashboards of IoT data.
Generate custom watchers for each customer with proper filters for each dashboard.
Email gets sent out to each customer with the PNG file.

I was able to receive the email but the png / pdf is not able to open. Can you verify my syntax ?

I am able to POST manually and it works, I just need to wait a few seconds to get the image file back.

Interesting use case. On Elastic Cloud, emails must be sent through EC servers and recipients must be whitelisted. Given those requirements, one possible workaround would be to setup your watchers as webhook actions instead: https://www.elastic.co/guide/en/x-pack/current/actions-webhook.html

This would require developing your own outside microservice for the watcher to hook into. The microservice would then be responsible for sending out the customer emails.

Of course, you could always ask your customers to kindly accept being whitelisted by Elastic Cloud :smiley:

Please refer to the documentation about attaching reporting to watcher email action: https://www.elastic.co/guide/en/x-pack/current/actions-email.html#email-action-reports

Thanks, I got I got the generated emails to my email now. all seems okay.

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