

# Monitoring MemoryDB events
<a name="monitoring-events"></a>

When significant events happen for a cluster, MemoryDB sends notification to a specific Amazon SNS topic. Examples include a failure to add a node, success in adding a node, the modification of a security group, and others. By monitoring for key events, you can know the current state of your clusters and, depending upon the event, be able to take corrective action.

**Topics**
+ [

# Managing MemoryDB Amazon SNS notifications
](mdbevents.sns.md)
+ [

# Viewing MemoryDB events
](mdbevents.viewing.md)
+ [

# Event Notifications and Amazon SNS
](memorydbsns.md)

# Managing MemoryDB Amazon SNS notifications
<a name="mdbevents.sns"></a>

You can configure MemoryDB to send notifications for important cluster events using Amazon Simple Notification Service (Amazon SNS). In these examples, you will configure a cluster with the Amazon Resource Name (ARN) of an Amazon SNS topic to receive notifications. 

**Note**  
This topic assumes that you've signed up for Amazon SNS and have set up and subscribed to an Amazon SNS topic. For information on how to do this, see the [Amazon Simple Notification Service Developer Guide](https://docs.aws.amazon.com/sns/latest/dg/). 

## Adding an Amazon SNS topic
<a name="mdbevents.sns.adding"></a>

The following sections show you how to add an Amazon SNS topic using the AWS Console, the AWS CLI, or the MemoryDB API.

### Adding an Amazon SNS topic (Console)
<a name="mdbevents.sns.addingclusters.viewdetails.console"></a>

 The following procedure shows you how to add an Amazon SNS topic for a cluster. 

**Note**  
 This process can also be used to modify the Amazon SNS topic. 

**To add or modify an Amazon SNS topic for a cluster (Console)**

1. Sign in to the AWS Management Console and open the MemoryDB console at [https://console.aws.amazon.com/memorydb/](https://console.aws.amazon.com/memorydb/).

1. In ** Clusters**, choose the cluster for which you want to add or modify an Amazon SNS topic ARN.

1. Choose **Modify**.

1. In **Modify Cluster** under **Topic for SNS Notification**, choose the SNS topic you want to add, or choose **Manual ARN input** and type the ARN of the Amazon SNS topic. 

1. Choose **Modify**.

### Adding an Amazon SNS topic (AWS CLI)
<a name="mdbevents.sns.adding.cli"></a>

To add or modify an Amazon SNS topic for a cluster, use the AWS CLI command `update-cluster`. 

The following code example adds an Amazon SNS topic arn to *my-cluster*.

For Linux, macOS, or Unix:

```
aws memorydb update-cluster \
    --cluster-name my-cluster \
    --sns-topic-arn arn:aws:sns:us-east-1:565419523791:memorydbNotifications
```

For Windows:

```
aws memorydb update-cluster ^
    --cluster-name my-cluster ^
    --sns-topic-arn arn:aws:sns:us-east-1:565419523791:memorydbNotifications
```

For more information, see [UpdateCluster](https://docs.aws.amazon.com/memorydb/latest/APIReference/API_UpdateCluster.html) .

### Adding an Amazon SNS topic (MemoryDB API)
<a name="mdbevents.sns.adding.api"></a>

To add or update an Amazon SNS topic for a cluster, call the `UpdateCluster` action with the following parameters:
+ `ClusterName``=my-cluster`
+ `SnsTopicArn``=arn%3Aaws%3Asns%3Aus-east-1%3A565419523791%3AmemorydbNotifications`

To add or update an Amazon SNS topic for a cluster, call the `UpdateCluster` action.

For more information, see [UpdateCluster](https://docs.aws.amazon.com/memorydb/latest/APIReference/API_UpdateCluster.html).

## Enabling and disabling Amazon SNS notifications
<a name="mdbevents.sns.disabling"></a>

 You can turn notifications on or off for a cluster. The following procedures show you how to disable Amazon SNS notifications. 

### Enabling and disabling Amazon SNS notifications (Console)
<a name="mdbevents.sns.disablingclusters.viewdetails.console"></a>

**To disable Amazon SNS notifications using the AWS Management Console**

1. Sign in to the AWS Management Console and open the MemoryDB console at [https://console.aws.amazon.com/memorydb/](https://console.aws.amazon.com/memorydb/).

1. Choose the radio button to the left of the cluster you want to modify notification for.

1. Choose **Modify**.

1. In **Modify Cluster** under **Topic for SNS Notification**, choose *Disable Notifications*.

1. Choose **Modify**.

### Enabling and disabling Amazon SNS notifications (AWS CLI)
<a name="mdbevents.sns.disabling.cli"></a>

To disable Amazon SNS notifications, use the command `update-cluster` with the following parameters:

For Linux, macOS, or Unix:

```
aws memorydb update-cluster \
    --cluster-name my-cluster \
    --sns-topic-status inactive
```

For Windows:

```
aws memorydb update-cluster ^
    --cluster-name my-cluster ^
    --sns-topic-status inactive
```

### Enabling and disabling Amazon SNS notifications (MemoryDB API)
<a name="mdbevents.sns.disabling.api"></a>

To disable Amazon SNS notifications, call the `UpdateCluster` action with the following parameters:
+ `ClusterName``=my-cluster`
+ `SnsTopicStatus``=inactive`

This call returns output similar to the following:

**Example**  

```
 1. https://memory-db.us-east-1.amazonaws.com/
 2.     ?Action=UpdateCluster    
 3.     &ClusterName=my-cluster
 4.     &SnsTopicStatus=inactive
 5.     &Version=2021-01-01
 6.     &SignatureVersion=4
 7.     &SignatureMethod=HmacSHA256
 8.     &Timestamp=20210801T220302Z
 9.     &X-Amz-Algorithm=Amazon4-HMAC-SHA256
10.     &X-Amz-Date=20210801T220302Z
11.     &X-Amz-SignedHeaders=Host
12.     &X-Amz-Expires=20210801T220302Z
13.     &X-Amz-Credential=<credential>
14.     &X-Amz-Signature=<signature>
```

# Viewing MemoryDB events
<a name="mdbevents.viewing"></a>

MemoryDB logs events that relate to your clusters, security groups, and parameter groups. This information includes the date and time of the event, the source name and source type of the event, and a description of the event. You can easily retrieve events from the log using the MemoryDB console, the AWS CLI `describe-events` command, or the MemoryDB API action `DescribeEvents`. 

The following procedures show you how to view all MemoryDB events for the past 24 hours (1440 minutes).

## Viewing MemoryDB events (Console)
<a name="mdbevents.viewingclusters.viewdetails"></a>

The following procedure displays events using the MemoryDB console.

**To view events using the MemoryDB console**

1. Sign in to the AWS Management Console and open the MemoryDB console at [https://console.aws.amazon.com/memorydb/](https://console.aws.amazon.com/memorydb/).

1. In the left navigation pane, choose **Events**.

   The *Events* screen appears listing all available events. Each row of the list represents one event and displays the event source, the event type (such as cluster, parameter-group, acl, security-group or subnet group), the GMT time of the event, and the description of the event.

   Using the **Filter** you can specify whether you want to see all events, or just events of a specific type in the event list.

## Viewing MemoryDB events (AWS CLI)
<a name="mdbevents.viewing.cli"></a>

To generate a list of MemoryDB events using the AWS CLI, use the command `describe-events`. You can use optional parameters to control the type of events listed, the time frame of the events listed, the maximum number of events to list, and more.

The following code lists up to 40 cluster events.

```
aws memorydb describe-events --source-type cluster --max-results 40  
```

The following code lists all events for the past 24 hours (1440 minutes).

```
aws memorydb describe-events --duration 1440  
```

The output from the `describe-events` command looks something like this.

```
{
    "Events": [        
        {
            "Date": "2021-03-29T22:17:37.781Z", 
            "Message": "Added node 0001 in Availability Zone us-east-1a", 
            "SourceName": "memorydb01", 
            "SourceType": "cluster"
        }, 
        {
            "Date": "2021-03-29T22:17:37.769Z", 
            "Message": "cluster created", 
            "SourceName": "memorydb01", 
            "SourceType": "cluster"
        }
    ]
}
```

For more information, such as available parameters and permitted parameter values, see [https://docs.aws.amazon.com/cli/latest/reference/memorydb/describe-events.html](https://docs.aws.amazon.com/cli/latest/reference/memorydb/describe-events.html).

## Viewing MemoryDB events (MemoryDB API)
<a name="mdbevents.viewing.api"></a>

To generate a list of MemoryDB events using the MemoryDB API, use the `DescribeEvents` action. You can use optional parameters to control the type of events listed, the time frame of the events listed, the maximum number of events to list, and more.

The following code lists the 40 most recent -cluster events.

```
https://memory-db.us-east-1.amazonaws.com/
   ?Action=DescribeEvents
   &MaxResults=40
   &SignatureVersion=4
   &SignatureMethod=HmacSHA256
   &SourceType=cluster
   &Timestamp=20210802T192317Z
   &Version=2021-01-01
   &X-Amz-Credential=<credential>
```

The following code lists the cluster events for the past 24 hours (1440 minutes).

```
https://memory-db.us-east-1.amazonaws.com/
   ?Action=DescribeEvents
   &Duration=1440
   &SignatureVersion=4
   &SignatureMethod=HmacSHA256
   &SourceType=cluster
   &Timestamp=20210802T192317Z
   &Version=2021-01-01
   &X-Amz-Credential=<credential>
```

The above actions should produce output similar to the following.

```
<DescribeEventsResponse xmlns="http://memory-db.us-east-1.amazonaws.com/doc/2021-01-01/"> 
    <DescribeEventsResult> 
        <Events> 
            <Event> 
                <Message>cluster created</Message> 
                <SourceType>cluster</SourceType> 
                <Date>2021-08-02T18:22:18.202Z</Date> 
                <SourceName>my-memorydb-primary</SourceName> 
            </Event> 
               
 (...output omitted...)
          
        </Events> 
    </DescribeEventsResult> 
    <ResponseMetadata> 
        <RequestId>e21c81b4-b9cd-11e3-8a16-7978bb24ffdf</RequestId> 
    </ResponseMetadata> 
</DescribeEventsResponse>
```

For more information, such as available parameters and permitted parameter values, see [https://docs.aws.amazon.com/memorydb/latest/APIReference/API_DescribeEvents.html](https://docs.aws.amazon.com/memorydb/latest/APIReference/API_DescribeEvents.html).

# Event Notifications and Amazon SNS
<a name="memorydbsns"></a>

MemoryDB can publish messages using Amazon Simple Notification Service (SNS) when significant events happen on a cluster. This feature can be used to refresh the server-lists on client machines connected to individual node endpoints of a cluster.

**Note**  
For more information on Amazon Simple Notification Service (SNS), including information on pricing and links to the Amazon SNS documentation, see the [Amazon SNS product page](https://aws.amazon.com/sns).

Notifications are published to a specified Amazon SNS *topic*. The following are requirements for notifications:
+ Only one topic can be configured for MemoryDB notifications.
+ The AWS account that owns the Amazon SNS topic must be the same account that owns the cluster on which notifications are enabled.

## MemoryDB Events
<a name="memorydbSNS.Events"></a>

The following MemoryDB events trigger Amazon SNS notifications:


| Event Name | Message | Description | 
| --- | --- | --- | 
|  MemoryDB:AddNodeComplete  |  "Modified number of nodes from %d to %d"  |  A node has been added to the cluster and is ready for use.  | 
|  MemoryDB:AddNodeFailed due to insufficient free IP addresses  |  "Failed to modify number of nodes from %d to %d due to insufficient free IP addresses"  |  A node could not be added because there are not enough available IP addresses.  | 
|  MemoryDB:ClusterParametersChanged  |  "Updated parameter group for the cluster" In case of create, also send `"Updated to use a ParameterGroup %s"`  |  One or more cluster parameters have been changed.  | 
|  MemoryDB:ClusterProvisioningComplete  |  "Cluster created."  |  The provisioning of a cluster is completed, and the nodes in the cluster are ready to use.  | 
|  MemoryDB:ClusterProvisioningFailed due to incompatible network state  |  "Failed to create cluster due to incompatible network state. %s"  |  An attempt was made to launch a new cluster into a nonexistent virtual private cloud (VPC).  | 
|  MemoryDB:ClusterRestoreFailed  |  "Restore from %s failed for node %s. %s"  |  MemoryDB was unable to populate the cluster with snapshot data. This could be due to a nonexistent snapshot file in Amazon S3, or incorrect permissions on that file. If you describe the cluster, the status will be `restore-failed`. You will need to delete the cluster and start over. For more information, see [Seeding a new cluster with an externally created snapshot](snapshots-seeding-redis.md).  | 
| MemoryDB:ClusterScalingComplete  | `"Succeeded applying modification to node type to %s."` | Scale up for cluster completed successfully. | 
| MemoryDB:ClusterScalingFailed | `"Failed applying modification to node type to %s."` | Scale-up operation on cluster failed.  | 
|  MemoryDB:NodeReplaceStarted  |  "Recovering node %s"  |  MemoryDB has detected that the host running a node is degraded or unreachable and has started replacing the node.  The DNS entry for the replaced node is not changed.  In most instances, you do not need to refresh the server-list for your clients when this event occurs. However, some client libraries may stop using the node even after MemoryDB has replaced the node; in this case, the application should refresh the server-list when this event occurs.  | 
|  MemoryDB:NodeReplaceComplete  |  "Finished recovery for node %s"  |  MemoryDB has detected that the host running a node is degraded or unreachable and has completed replacing the node.  The DNS entry for the replaced node is not changed.  In most instances, you do not need to refresh the server-list for your clients when this event occurs. However, some client libraries may stop using the node even after MemoryDB has replaced the node; in this case, the application should refresh the server-list when this event occurs.  | 
|  MemoryDB:CreateClusterComplete  |  "Cluster created"  |  The cluster was successfully created.  | 
|  MemoryDB:CreateClusterFailed  |  "Failed to create cluster due to unsuccessful creation of its node(s)." and "Deleting all nodes belonging to this cluster."  |  The cluster was not created.  | 
|  MemoryDB:DeleteClusterComplete  |  "Cluster deleted."  |  The deletion of a cluster and all associated nodes has completed.  | 
| MemoryDB:FailoverComplete | `"Failover to replica node %s completed"` | Failover over to a replica node was successful. | 
|  MemoryDB:NodeReplacementCanceled  |  "The replacement of node %s which was scheduled during the maintenance window from start time: %s, end time: %s has been canceled"  |  A node in your cluster that was scheduled for replacement is no longer scheduled for replacement.   | 
|  MemoryDB:NodeReplacementRescheduled  |  "The replacement in maintenance window for node %s has been re-scheduled from previous start time: %s, previous end time: %s to new start time: %s, new end time: %s"  |  A node in your cluster previously scheduled for replacement has been rescheduled for replacement during the new window described in the notification.  For information on what actions you can take, see [Replacing nodes](nodes.nodereplacement.md).  | 
|  MemoryDB:NodeReplacementScheduled  |  "The node %s is scheduled for replacement during the maintenance window from start time: %s to end time: %s"  |  A node in your cluster is scheduled for replacement during the window described in the notification.  For information on what actions you can take, see [Replacing nodes](nodes.nodereplacement.md).  | 
|  MemoryDB:RemoveNodeComplete  |  "Removed node %s"  |  A node has been removed from the cluster.  | 
|  MemoryDB:SnapshotComplete  |  "Snapshot %s succeeded for node %s"  |  A snapshot has completed successfully.  | 
|  MemoryDB:SnapshotFailed  |  "Snapshot %s failed for node %s"  |  A snapshot has failed. See the cluster’s events for more a detailed cause. If you describe the snapshot, see [DescribeSnapshots](https://docs.aws.amazon.com/memorydb/latest/APIReference/API_DescribeSnapshots.html), the status will be `failed`.  | 