A newer version of this documentation is available.

View Latest

Setting Email Notifications

Alert settings specify whether email alerts are sent and the events that trigger emails. This is a global setting for all clusters. Authentication is required to read this value.

Getting Alert Settings

Email alerts can be dispatched automatically when a significant error occurs — see Configure Email Alerts.

HTTP method and URI

GET /settings/alerts

Syntax

Curl request syntax:

curl -u [admin]:[password ]
    http://[localhost]:8091/settings/alerts

Raw HTTP request syntax:

GET /settings/alerts HTTP/1.1
Host: [localhost]:8091
Authorization: Basic YWRtaW46YWRtaW4= Accept: */*

Example

Curl request example:

curl -u Administrator:password
    http://10.5.2.54:8091/settings/alerts

Raw HTTP request example:

GET /settings/alerts HTTP/1.1
Host: 10.5.2.54:8091
Authorization: Basic YWRtaW46YWRtaW4= Accept: */*

Response

{
    "alerts": [
        "auto_failover_node",
        "auto_failover_maximum_reached",
        "auto_failover_other_nodes_down",
        "auto_failover_cluster_too_small",
        "ip",
        "disk",
        "overhead",
        "ep_oom_errors",
        "ep_item_commit_failed"
    ],
    "emailServer": {
        "encrypt": false,
        "host": "localhost",
        "pass": "",
        "port": 25,
        "user": ""
    },
    "enabled": false,
    "recipients": [
        "root@localhost"
    ],
    "sender": "couchbase@localhost"
}
For security reasons, the pass field of the emailServer is always empty.

Response codes

Possible errors include:

This endpoint isn't available yet.

Enabling and disabling email notifications

HTTP method and URI

This is a global setting for all clusters. Authentication is required to change this value. If this is enabled, Couchbase Server sends an email when certain events occur. Only events related to auto-failover trigger notification.

POST /settings/alerts

Possible parameters include:

  • alerts (string) (optional, default: auto_failover_node, auto_failover_maximum_reached, auto_failover_other_nodes_down, auto_failover_cluster_too_small). Comma separated list of alerts that should cause an email to be sent. Possible values are: auto_failover_node, auto_failover_maximum_reached, auto_failover_other_nodes_down, auto_failover_cluster_too_small.

  • enabled : (true | false) (required). Whether to enable or disable email notifications

  • sender (string) (optional, default: couchbase@localhost). Email address of the sender.

  • recipients (string) (required). A comma separated list of recipients of the of the emails.

  • emailServer host (string) (optional, default: localhost). Host address of the SMTP server

  • emailServer port (integer) (optional, default: 25). Port of the SMTP server

  • emailServer encrypt (true | false) (optional, default: false). Whether you want to use TLS or not

  • emailServer user (string) (optional, default: ""): Username for the SMTP server

  • emailServer pass (string) (optional, default: ""): Password for the SMTP server

Syntax

Curl request syntax:

curl -i -u [admin]:[password]
    http://[localhost]:8091/settings/alerts
    -d [parameter]

Example

Curl request example:

curl -i -u Administrator:password \
    http://10.5.2.54:8091/settings/alerts \
    -d 'enabled=true&sender=couchbase@10.5.2.54&recipients=admin@10.5.2.54,membi@10.5.2.54&emailHost= \
    10.5.2.54&emailPort=25&emailEncrypt=false'

Raw request example:

POST /settings/alerts HTTP/1.1
Host: 10.5.2.54:8091
Content-Type: application/x-www-form-urlencoded
Authorization: Basic YWRtaW46YWRtaW4=
Content-Length: 14 enabled=true&sender=couchbase@10.5.2.54&recipients=admin@10.5.2.54,membi@localhost&emailHost= \
10.5.2.54&emailPort=25&emailEncrypt=false�

Response codes

HTTP/1.1 200 OK

Possible HTTP errors include:

400 Bad Request
401 Unauthorized
JSON object ({"errors": {"key": "error"}}) with errors.

Possible errors returned in a JSON document include:

  • alerts: alerts contained invalid keys. Valid keys are: [list_of_keys].

  • email_encrypt: emailEncrypt must be either true or false.

  • email_port: emailPort must be a positive integer less than 65536.

  • enabled: enabled must be either true or false.

  • recipients: recipients must be a comma separated list of valid email addresses.

  • sender: sender must be a valid email address.

  • general: No valid parameters given.

Sending test emails

HTTP method and URI

POST /settings/alerts/sendTestEmail

Syntax

Curl request syntax:

curl -i -u admin:password
    http://localhost:8091/settings/alerts/testEmail \
    -d [parameter]

Raw HTTP request syntax

POST /settings/alerts/sendTestEmail HTTP/1.1
Host: [localhost]:8091
Content-Type: application/x-www-form-urlencoded
Authorization: Basic YWRtaW46YWRtaW4=

Example

Curl request example:

curl -i -u Administrator:password \
    http://10.5.2.54:8091/settings/alerts/testEmail \
    -d 'subject=Test+email+from+Couchbase& \
    body=This+email+was+sent+to+you+to+test+the+email+alert+email+server+settings.&enabled=true& \
    recipients=vmx%4010.5.2.54&sender=couchbase%4010.5.2.54& \
    emailUser=&emailPass=&emailHost=10.5.2.54&emailPort=25&emailEncrypt=false& \
    alerts=auto_failover_node%2Cauto_ \
    failover_maximum_reached%2Cauto_failover_other_nodes_down%2Cauto_failover_cluster_too_small'

Raw HTTP request example:

POST /settings/alerts/sendTestEmail HTTP/1.1
Host: 10.5.2.54:8091
Content-Type: application/x-www-form-urlencoded
Authorization: Basic YWRtaW46YWRtaW4=

Response codes

Possible response code include:

200 OK
400 Bad Request: Unknown macro: {"error"} 401 Unauthorized
This endpoint isn't available yet.