# Trigger return true but no alerts received 1.7.0

**URL:** <https://forum.opensearch.org/t/trigger-return-true-but-no-alerts-received-1-7-0/2931>\
**Category:** Alerting\
**Tags:** troubleshoot\
**Created:** [May 29, 2020, 7:13pm UTC](https://forum.opensearch.org/t/trigger-return-true-but-no-alerts-received-1-7-0/2931 "2020-05-29T19:13:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![hilo21](https://avatars.discourse-cdn.com/v4/letter/h/bbce88/32.png) [@hilo21](https://forum.opensearch.org/u/hilo21)\
**Post date:** [May 29, 2020, 7:13pm UTC](https://forum.opensearch.org/t/trigger-return-true-but-no-alerts-received-1-7-0/2931/1 "2020-05-29T19:13:56Z")

</div>

Context :

- **Open Distro alerting plugin version 1.7.0**
- **Elastic stack version 7.6.1**
- **3 nodes : 1 master-only and Kibana node + 2 data nodes**
- **Type : Extraction Query**
- **Trigger purpose : Vertical Scan Security Detection**  
Query :

> ```
> {
> 
> "size": 0,
> 
> "query": {
> 
> "bool": {
> 
> "must": [
> 
> {
> 
> "match": {
> 
> "tags": "firewall"
> 
> }
> 
> },
> 
> {
> 
> "range": {
> 
> "@timestamp": {
> 
> "gte": "now-30s"
> 
> }
> 
> }
> 
> }
> 
> ]
> 
> }
> 
> },
> 
> "aggs": {
> 
> "by_src_ip": {
> 
> "terms": {
> 
> "field": "source.ip"
> 
> },
> 
> "aggs": {
> 
> "by_target_ip": {
> 
> "terms": {
> 
> "field": "destination.ip",
> 
> "order": {
> 
> "unique_port_count": "desc"
> 
> }
> 
> },
> 
> "aggs": {
> 
> "unique_port_count": {
> 
> "cardinality": {
> 
> "field": "destination.port"
> 
> }
> 
> }
> 
> }
> 
> }
> 
> }
> 
> }
> 
> }
> 
> }
> 
> ```

Trigger code :

```
int incident = 0;
for (int i = 0; i < ctx.results[0].aggregations.by_src_ip.buckets.size(); i++) {
    for (int j = 0; j < ctx.results[0].aggregations.by_src_ip.buckets[i].by_target_ip.buckets.size(); j++) {
        if (ctx.results[0].aggregations.by_src_ip.buckets[i].by_target_ip.buckets[j].unique_port_count.value > 1) {
            incident += 1;
        }
    }
}
if (incident !== 0) {
  return true;
} else {
  return false;
}

```

 ![image](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/1X/f1f22505f53819cdcc9568fe255bcf7edb910cd0.png)

Rule is executed every 1 minute.

Alerting Stats :

> ```
> > {
> > "_nodes" : {
> > "total" : 3,
> > "successful" : 3,
> > "failed" : 0
> > },
> > "cluster_name" : "hidden",
> > "opendistro.scheduled_jobs.enabled" : true,
> > "scheduled_job_index_exists" : true,
> > "scheduled_job_index_status" : "green",
> > "nodes_on_schedule" : 3,
> > "nodes_not_on_schedule" : 0,
> > "nodes" : {
> > "GTPXL8OsRTyxf69sYiPtfQ" : {
> > "name" : "elk-master",
> > "schedule_status" : "green",
> > "roles" : [
> > "MASTER"
> > ],
> > "job_scheduling_metrics" : {
> > "last_full_sweep_time_millis" : 268316,
> > "full_sweep_on_time" : true
> > },
> > "jobs_info" : { }
> > },
> > "U9y1CQ9ISY6qKKeUyiXuEg" : {
> > "name" : "elk-data-hot",
> > "schedule_status" : "green",
> > "roles" : [
> > "INGEST",
> > "MASTER",
> > "DATA",
> > "ML"
> > ],
> > "job_scheduling_metrics" : {
> > "last_full_sweep_time_millis" : 178600,
> > "full_sweep_on_time" : true
> > },
> > "jobs_info" : {
> > "Bi17YHIBaJTCGwydrJUA" : {
> > "last_execution_time" : 1590778817201,
> > "running_on_time" : true
> > },
> > "Jy7UYHIBaJTCGwyd_ciH" : {
> > "last_execution_time" : 1590779150786,
> > "running_on_time" : true
> > },
> > "oi-TYXIBW13vr6nbOo7x" : {
> > "last_execution_time" : 1590779138317,
> > "running_on_time" : true
> > }
> > }
> > },
> > "THcNACa9QwCli9SUfpgcRA" : {
> > "name" : "elk-data-warm",
> > "schedule_status" : "green",
> > "roles" : [
> > "INGEST",
> > "MASTER",
> > "DATA",
> > "ML"
> > ],
> > "job_scheduling_metrics" : {
> > "last_full_sweep_time_millis" : 59349,
> > "full_sweep_on_time" : true
> > },
> > "jobs_info" : {
> > "Ihf1JXIB1bbtyrEkZ-kL" : {
> > "last_execution_time" : 1590779199206,
> > "running_on_time" : true
> > }
> > }
> > }
> > }
> > }
> 
> ```

Result when i run it locally :

> [ALERT] Network Enumeration/Reconnaissance : Internal Vertical Scan
> 
> - Message : A vertical scan was detected
> - Trigger: Port Scan
> - Severity: 3
> - Source :  
> - Source IP: hidden, Event Count: 120  
> - Source IP: hidden, Event Count: 64  
> - Source IP: hidden, Event Count: 9  
> - Source IP: hidden, Event Count: 9  
> - Source IP: hidden, Event Count: 9  
> - Source IP: hidden, Event Count: 8  
> - Source IP: hidden, Event Count: 7  
> - Source IP: hidden, Event Count: 5  
> - Source IP: hidden, Event Count: 4  
> - Source IP: hidden, Event Count: 4
> - Period start: 2020-05-29T18:44:11Z

My slak destination is working also my alerting installation since I still receive alerts by other monitros.

When i go to trigger INFO I see this at the end :

> “triggers”: {  
> “Port Scan”: {  
> “value”: 10000,  
> “enum”: “ABOVE”  
> }  
> }

What does this mean ?  
My trigger is apparently working but why i don’t receive any alerts. I tried to lower the unique number of ports to make sure that an alert should match but still nothing

---

<div class="post-metadata">

**Author:** ![hilo21](https://avatars.discourse-cdn.com/v4/letter/h/bbce88/32.png) [@hilo21](https://forum.opensearch.org/u/hilo21)\
**Post date:** [May 30, 2020, 5:30pm UTC](https://forum.opensearch.org/t/trigger-return-true-but-no-alerts-received-1-7-0/2931/2 "2020-05-30T17:30:08Z")

</div>

Hello,

Do I need Anomaly Detector for this type of queries ? I mean is the extraction query focuses around hits but no aggregations ?

Thanks

---

<div class="post-metadata">

**Author:** ![hilo21](https://avatars.discourse-cdn.com/v4/letter/h/bbce88/32.png) [@hilo21](https://forum.opensearch.org/u/hilo21)\
**Post date:** [June 1, 2020, 3:21pm UTC](https://forum.opensearch.org/t/trigger-return-true-but-no-alerts-received-1-7-0/2931/3 "2020-06-01T15:21:59Z")

</div>

Can someone give me some thoughts around this please

---

<div class="post-metadata">

**Author:** ![alolitas](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@alolitas](https://forum.opensearch.org/u/alolitas)\
**Post date:** [June 2, 2020, 7:29am UTC](https://forum.opensearch.org/t/trigger-return-true-but-no-alerts-received-1-7-0/2931/4 "2020-06-02T07:29:47Z")

</div>

Hi @hilo21 can you open an issue on [GitHub - opendistro-for-elasticsearch/anomaly-detection: A machine learning plugin in Open Distro for real time anomaly detection on streaming data.](https://github.com/opendistro-for-elasticsearch/anomaly-detection) - Thanks.

---

<div class="post-metadata">

**Author:** ![hilo21](https://avatars.discourse-cdn.com/v4/letter/h/bbce88/32.png) [@hilo21](https://forum.opensearch.org/u/hilo21)\
**Post date:** [June 3, 2020, 1:58pm UTC](https://forum.opensearch.org/t/trigger-return-true-but-no-alerts-received-1-7-0/2931/5 "2020-06-03T13:58:02Z")

</div>

Hello @alolitas,

I did open an issue and they closed it because it had nothing to do anomaly detection but alerting.  
I did open an issue in the alerting repo before this one but nothing yet !

Can someone provide some feedback about the different paths to take?

Thank you

---

<div class="post-metadata">

**Author:** ![FREDDIE2020](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/freddie2020/32/969_2.png) [@FREDDIE2020](https://forum.opensearch.org/u/FREDDIE2020)\
**Post date:** [June 24, 2020, 1:31pm UTC](https://forum.opensearch.org/t/trigger-return-true-but-no-alerts-received-1-7-0/2931/6 "2020-06-24T13:31:54Z")

</div>

Hi,  
I am having same issue. Trigger works fine, but no alerting via SNS or email. Even when I perform manual Test message button.

Any ideas on this issue?

Freddie2020

---

<div class="post-metadata">

**Author:** ![deepsh4h](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@deepsh4h](https://forum.opensearch.org/u/deepsh4h)\
**Post date:** [July 1, 2020, 10:03pm UTC](https://forum.opensearch.org/t/trigger-return-true-but-no-alerts-received-1-7-0/2931/7 "2020-07-01T22:03:08Z")

</div>

Hi,

I’ve got the same issue, when I run manually the **trigger condition response** returns **true** but doesn’t trigger an alert automatically.

The history says “ **No alerts** ”.

Using Elastic Stack: 7.6.1

---

<div class="post-metadata">

**Author:** ![tddu](https://avatars.discourse-cdn.com/v4/letter/t/b5a626/32.png) [@tddu](https://forum.opensearch.org/u/tddu)\
**Post date:** [February 3, 2022, 7:28pm UTC](https://forum.opensearch.org/t/trigger-return-true-but-no-alerts-received-1-7-0/2931/8 "2022-02-03T19:28:00Z")

</div>

Is there any resolve here?
