In order to test this function, I chosed **Abnormal Request Count** option, which is in Alert Management menu of Api Store, and added a restful api. Then I called this api for many times by Postman.

The carbon.log, which is in `<API-M_ANALYTICS_HOME>/wso2/worker/logs`, recorded the following error message:

```
[2020-10-19 11:03:36,094] ERROR {org.wso2.siddhi.core.stream.output.sink.Sink} - Error on 'APIM_ALERT_EMAIL_NOTIFICATION'. Dropping event at Sink 'email' at 'EmailNotificationStream' as its still trying to reconnect!, events dropped '<strong>Message:</strong>A request from a new IP (10.9.16.77) detected by user:admin@carbon.super using application:devMap owned by admin@carbon.super. <br><br> <strong>Type:</strong>UnusualIPAccess <br><br> <strong>AlertTimestamp:</strong>2020-10-19 11:03:35'
[2020-10-19 11:06:10,307] ERROR {org.wso2.siddhi.core.stream.output.sink.Sink} - Error on 'APIM_ALERT_EMAIL_NOTIFICATION'. Dropping event at Sink 'email' at 'EmailNotificationStream' as its still trying to reconnect!, events dropped '<strong>Message:</strong>Abnormal request count detected during last minute using application devMap owned by admin@carbon.super for api :全球风向查询, abnormal request count:9. <br><br> <strong>Type:</strong>AbnormalRequestsPerMin <br><br> <strong>AlertTimestamp:</strong>2020-10-19 11:06:10'

```

About detailed configuration, I referred the following links:

1. Configuring Alerts:
*<https://docs.wso2.com/display/AM260/Configuring+Alerts#ConfiguringAlerts-ConfiguringalertsviatheStore>*
2. Enabling Notifications:
*<https://docs.wso2.com/display/AM260/Enabling+Notifications>*

According to these documents, I did the following things:

1.Open the <API-M\_ANALYTICS\_HOME>/conf/worker/deployment.yaml file to configure the sender email address. The sample code is shown below:

```
siddhi:
  extensions:
...
    -
      extension:
        name: email
        namespace: sink
        properties:
          username: abcd@163.com
          address: abcd@163.com
          password: xxxx
...

```

2.Go to the <API-M\_ANALYTICS\_HOME>/resources/apim-analytics/ directory. Copy the APIM\_ALERT\_EMAIL\_NOTIFICATION.siddhi file and paste it in the <API-M\_ANALYTICS\_HOME>/wso2/worker/deployment/siddhi-files directory.

3.Set the email server configurations in the <API-M\_HOME>/repository/conf/output-event-adapters.xml file under the section.

```
<adapterConfig type="email">
       <!-- Comment mail.smtp.user and mail.smtp.password properties to support connecting SMTP servers which use trust
       based authentication rather username/password authentication -->
       <property key="mail.smtp.from">abcd@163.com</property>
       <property key="mail.smtp.user">abcd</property>
       <property key="mail.smtp.password">xxxx</property>
       <property key="mail.smtp.host">smtp.163.com</property>
       <property key="mail.smtp.port">25</property>
       <property key="mail.smtp.starttls.enable">true</property>
       <property key="mail.smtp.auth">true</property>
       <!-- Thread Pool Related Properties -->
       <property key="minThread">8</property>
       <property key="maxThread">100</property>
       <property key="keepAliveTimeInMillis">20000</property>
       <property key="jobQueueSize">10000</property>
   </adapterConfig>

```

4.Log in to the Management Console and click Main > Resource > Browse. Browse to the /\_system/config/apimgt/applicationdata/tenant-conf.json file and click Edit as Text.Set the NotificationsEnabled property to true as shown below:

```
"NotificationsEnabled":"true",
  "Notifications":[{
    "Type":"new_api_version",
    "Notifiers" :[{
      "Class":"org.wso2.carbon.apimgt.impl.notification.NewAPIVersionEmailNotifier",
      "ClaimsRetrieverImplClass":"org.wso2.carbon.apimgt.impl.token.DefaultClaimsRetriever",
      "Title": "Version $2 of $1 Released",
      "Template": " <html> <body> <h3 style=\"color:Black;\">We’re happy to announce the arrival of the next major version $2 of $1 API which is now available in Our API Store.</h3><a href=\"https://localhost:9443/store\">Click here to Visit WSO2 API Store</a></body></html>"

    }]
  }
  ]

```

I've also checked APIM\_ALERT\_EMAIL\_NOTIFICATION.siddhi:

```
@App:name("APIM_ALERT_EMAIL_NOTIFICATION")
@App:description('Send email to all the subscribers of a particular alert') 

@source(type="inMemory", topic="APIM_EMAIL_NOTIFICATION", @map(type='passThrough'))
define stream EmailAlertStream (
    type    string, 
    message string, 
    alertTimestamp  string, 
    emails  string);

@sink(type='email', content.type="text/html", @map(type ='text', @payload('<strong>Message:</strong>{{message}} <br><br> <strong>Type:</strong>{{type}} <br><br> <strong>AlertTimestamp:</strong>{{alertTimestamp}}')),subject='Alerts from WSO2 APIM Analytics',to='{{emails}}')
define stream EmailNotificationStream (
    type    string,
    message string,
    alertTimestamp  string,
    emails  string);

from EmailAlertStream
select *
insert into EmailNotificationStream;

```

As you can see, there is nothing special.

Have I missed anything to do? I don't know what the problem is, please help me.