Cannot find default email account as no accounts have been configured

Everytime I execute my Watch I get this error:

   {
      "id" : "send_email",
      "type" : "email",
      "status" : "failure",
      "reason" : "IllegalStateException[cannot find default email account as no accounts have been configured]"
    }

I have tried many different alternatives but nothing seems to work. As far as I can tell the configuration is correct, but yet I keep getting the same error message.

Elasticsearch.yml:

xpack.notification.email.account:
      standard_account: 
         profile: standard
         smtp:  
             auth: false
             starttls.enable: false
             host: smtp.mysite.com
             port: 25

The Watcher:

"send_email": {
    "email" : {
      "to" : "user@mysite.com",
        "subject" : "Testing Email Delivery Alerting",
           "body" : "Body content goes here"
  }}
 }
 }

The indentation is also correct from what I have read with similar issues...

Hey,

can you please use proper formatting to check the indentation of your configuration? The this markdown cheat sheet for code highlighting.

Which Elasticsearch version are you using?

--Alex

I have adjusted the formatting to show indentation. We are using ES 5.

5.0.0-alpha5. (I work with Ian)

Hey,

so I took your configuration, copy pasted it into my alpha5 elasticsearch.yml configuration after installing x-pack and started up. Saw this in the logs

[2016-09-12 11:43:01,487][INFO ][xpack.notification.email ] [bfnTYGv] default account set to [standard_account]

This is my elasticsearch.yaml configuration

xpack.security.enabled: false

xpack.notification.email.account:
      standard_account:
         profile: standard
         smtp:
             auth: false
             starttls.enable: false
             host: localhost
             port: 1025

Setting up and executing this watch, lead to an email in my test mail server (I used maildev, a neat node.js package you install via npm install -g maildev, start via maildev -v and then you can open http://localhost:1080 for a nice web interface to check the emails you get send to localhost:1025.

PUT _xpack/watcher/watch/my-watch
{
  "trigger": {
    "schedule": {
      "interval": "20h"
    }
  },
  "actions": {
    "send_email": {
      "email": {
        "to": "user@mysite.com",
        "subject": "Testing Email Delivery Alerting",
        "body": "Body content goes here"
      }
    }
  }
}

PUT _xpack/watcher/watch/my-watch/_execute

So, you config parameters seem to be correct.

  • Can you verify the default account is shown on start up?
  • Can you show the full configuration of that node? Maybe something gets overwritten? Just run grep "^[^#]" elasticsearch.yml - this returns all lines that are not comments.
  • Can you try with a configuration like the above (only the bare needed one) and see if that changes anything?

Let's see if we spot somthing

--Alex

Everything from your list checks out; however, I am still getting the same issue.

  1. According to the logs "default account set to [standard_account]"
  2. An important exception to your example and mine was that I have to have xpack.security.enabled: true
  3. I even created a bare components watch similar to your example, and still the same result.
  4. Running grep "^[^#]" elasticsearch.yml showed all the configs as expected.

Hey,

can you provide the full/exact configuration file somewhere?

Also, just to be sure, I tested with security enabled and it worked as well.

--Alex

Hey,

also, what happens, when you manually specify the account in the watch, like this?

      "email": {
        "to": "user@mysite.com",
        "subject": "Testing Email Delivery Alerting",
        "body": "Body content goes here",
        "account" : "standard_account"
      }

--Alex

Below is the output from running the Watch with the standard_account included. It would appear that it is having trouble identifying the standard_account setup. Perhaps there is a disconnect between when the Watch is executed and the file(s) providing default configuration? In particular, the xpack.notification.email.account information and native SMTP in elasticsearch.yml.

  {
      "_id" : "my-watch_0-2016-09-13T15:30:14.222Z",
      "watch_record" : {
        "watch_id" : "my-watch",
        "state" : "executed",
        "trigger_event" : {
          "type" : "manual",
          "triggered_time" : "2016-09-13T15:30:14.222Z",
          "manual" : {
            "schedule" : {
              "scheduled_time" : "2016-09-13T15:30:14.222Z"
            }
          }
        },
        "input" : {
          "none" : { }
        },
        "condition" : {
          "always" : { }
        },
        "result" : {
          "execution_time" : "2016-09-13T15:30:14.222Z",
          "execution_duration" : 0,
          "input" : {
            "type" : "none",
            "status" : "success",
            "payload" : { }
          },
          "condition" : {
            "type" : "always",
            "status" : "success",
            "met" : true
          },
          "actions" : [
            {
              "id" : "send_email",
              "type" : "email",
              "status" : "failure",
              "reason" : "IllegalArgumentException[failed to send email with subject [Testing Email Delivery Alerting] via account [standard_account]. account does not exist]"
            }
          ]
        },
        "messages" : [ ]
      }
    }

The elasticsearch.yml setup is as follows with the critical information stripped and replaced with dummy information:

# ======================== Elasticsearch Configuration =========================
#
# ---------------------------------- Cluster -----------------------------------
#
cluster.name: "ClusterName"
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: "cn#@node#"
node.data: false
node.master: false
node.ingest: true
#
# Add custom attributes to the node:
#
# node.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.home: ${ES_HOME}
path.conf: ${ES_CONF_DIR}
path.data: ${ES_DATA_DIR}
path.logs: ${LOG_DIR}
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
# bootstrap.memory_lock: true
#
# Elasticsearch performs poorly when the system is swapping the memory.
 # ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: <Native Host Address>
#
# Set a custom port for HTTP:
#
http.port: 9205
transport.tcp.port: 9305
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.zen.ping.unicast.hosts: [ "<Master Node>:9305" ]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
#
discovery.zen.minimum_master_nodes: 4
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>
#
# ---------------------------------- Gateway -----------------------------------
#
# All set to defaults
#
# ---------------------------------- Various -----------------------------------

script.inline: true
script.stored: true
script.engine.groovy.inline.search: on
thread_pool.bulk.queue_size: 1000
# --------------------------------------------------------------------------------
# SMTP Email Server config
# -------------------------------------------------------------------------------

xpack.notification.email.account:
      standard_account:
         profile: standard
         smtp:
             auth: false
             starttls.enable: false
             starttls.required: false
             host: localhost
             port: 25

Hey,

are you sure that you put the above configuration on every node and restarted it? Especially on the current master as this is where the watch is being executed?

--Alex

Alex,

It appears that some nodes were missing the update in elasticsearch.yml, when I went and applied that exact elasticsearch.yml (Copy/Paste) the results then became as follows:

"actions" : [
        {
          "id" : "send_email",
          "type" : "email",
          "status" : "failure",
          "reason" : "NullPointerException[null]"
        }
      ]
    },

As a reminder the ES files were appended with:

xpack.notification.email.account:
      standard_account:
         profile: standard
         smtp:
             auth: false
             starttls.enable: false
             starttls.required: false
             host: localhost
             port: 25

Hey,

are there exceptions in your logs on the master node and can you check the watch history and get the latest entry for that watch?

--Alex

So, the Error Message from ES is as follows; I am not aware of any other logs I should be checking so if there is anything else let me know. The Watch History doesn't appear to show anything value either.

[ERROR][xpack.watcher.actions.email] [ES@MN] failed to execute action [queue/send_email]
java.lang.NullPointerException
at org.elasticsearch.xpack.notification.email.Account.send(Account.java:111)
at org.elasticsearch.xpack.notification.email.EmailService.send(EmailService.java:70)
at org.elasticsearch.xpack.notification.email.EmailService.send(EmailService.java:64)
at org.elasticsearch.xpack.watcher.actions.email.ExecutableEmailAction.execute(ExecutableEmailAction.java:85)
at org.elasticsearch.xpack.watcher.actions.ActionWrapper.execute(ActionWrapper.java:109)
at org.elasticsearch.xpack.watcher.execution.ExecutionService.executeInner(ExecutionService.java:404)
at org.elasticsearch.xpack.watcher.execution.ExecutionService.execute(ExecutionService.java:280)
at org.elasticsearch.xpack.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:476)
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:450)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Hey,

did you specify a from address in the account configuration or the watch?

Just for testing, can you add a default from?

xpack.notification.email.account:
  standard_account:
    profile: standard
    email_defaults:
      from: foo@bar.org
    smtp:
      auth: false
      starttls.enable: false
      host: localhost
      port: 1025

--Alex