# No Results In Execution Output Watcher|Elasticsearch

**URL:** <https://discuss.elastic.co/t/no-results-in-execution-output-watcher-elasticsearch/198539>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [September 8, 2019, 6:58am UTC](https://discuss.elastic.co/t/no-results-in-execution-output-watcher-elasticsearch/198539 "2019-09-08T06:58:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ntran](https://avatars.discourse-cdn.com/v4/letter/n/73ab20/32.png) [@ntran](https://discuss.elastic.co/u/ntran)\
**Post date:** [September 8, 2019, 6:58am UTC](https://discuss.elastic.co/t/no-results-in-execution-output-watcher-elasticsearch/198539/1 "2019-09-08T06:58:58Z")

</div>

Hi everyone,

I was looking at my results from my watcher and while it states `execution_not_needed`, when I look at the execution output, there are no results from my query.  
Is this normal behaviour?

// Execution Output

```
{
  "watch_id": "disk_usage",
  "node": "7PFUTZb6RgKmI38clwXr2g",
  "state": "execution_not_needed",
  "user": "ttran",
  "status": {
    "state": {
      "active": true,
      "timestamp": "2019-09-05T05:58:31.135Z"
    },
    "last_checked": "2019-09-08T05:59:05.686Z",
    "actions": {
      "notify-slack": {
        "ack": {
          "timestamp": "2019-09-05T05:58:31.135Z",
          "state": "awaits_successful_execution"
        }
      }
    },
    "execution_state": "execution_not_needed",
    "version": -1
  },
  "trigger_event": {
    "type": "schedule",
    "triggered_time": "2019-09-08T05:59:05.686Z",
    "schedule": {
      "scheduled_time": "2019-09-08T05:59:05.428Z"
    }
  },
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "index*"
        ],
        "types": [
          "doc"
        ],
        "rest_total_hits_as_int": true,
        "body": {
          "query": {
            "bool": {
              "filter": [
                {
                  "range": {
                    "timestamp": {
                      "gte": "{{ctx.trigger.scheduled_time}}||-5m"
                    }
                  }
                },
                {
                  "term": {
                    "type": {
                      "value": "node_stats"
                    }
                  }
                }
              ]
            }
          },
          "aggs": {
            "nodes": {
              "terms": {
                "field": "source_node.name",
                "size": 100
              },
              "aggs": {
                "total_in_bytes": {
                  "max": {
                    "field": "node_stats.fs.total.total_in_bytes"
                  }
                },
                "available_in_bytes": {
                  "max": {
                    "field": "node_stats.fs.total.available_in_bytes"
                  }
                },
                "free_ratio": {
                  "bucket_script": {
                    "buckets_path": {
                      "available_in_bytes": "available_in_bytes",
                      "total_in_bytes": "total_in_bytes"
                    },
                    "script": "params.available_in_bytes / params.total_in_bytes"
                  }
                }
              }
            }
          },
          "size": 0
        }
      }
    }
  },
  "condition": {
    "script": {
      "source": "return ctx.payload.aggregations.nodes.buckets.stream().anyMatch(it -> it.free_ratio.value < ctx.metadata.lower_bound);",
      "lang": "painless"
    }
  },
  "metadata": {
    "cluster": "hrc",
    "lower_bound": 0.25
  },
  "result": {
    "execution_time": "2019-09-08T05:59:05.686Z",
    "execution_duration": 4,
    "input": {
      "type": "search",
      "status": "success",
      "payload": {
        "_shards": {
          "total": 7,
          "failed": 0,
          "successful": 7,
          "skipped": 0
        },
        "hits": {
          "hits": [],
          "total": 0,
          "max_score": null
        },
        "took": 4,
        "timed_out": false,
        "aggregations": {
          "nodes": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": []
          }
        }
      },
      "search": {
        "request": {
          "search_type": "query_then_fetch",
          "indices": [
            "index*"
          ],
          "types": [
            "doc"
          ],
          "rest_total_hits_as_int": true,
          "body": {
            "query": {
              "bool": {
                "filter": [
                  {
                    "range": {
                      "timestamp": {
                        "gte": "2019-09-08T05:59:05.428Z||-5m"
                      }
                    }
                  },
                  {
                    "term": {
                      "type": {
                        "value": "node_stats"
                      }
                    }
                  }
                ]
              }
            },
            "aggs": {
              "nodes": {
                "terms": {
                  "field": "source_node.name",
                  "size": 100
                },
                "aggs": {
                  "total_in_bytes": {
                    "max": {
                      "field": "node_stats.fs.total.total_in_bytes"
                    }
                  },
                  "available_in_bytes": {
                    "max": {
                      "field": "node_stats.fs.total.available_in_bytes"
                    }
                  },
                  "free_ratio": {
                    "bucket_script": {
                      "buckets_path": {
                        "available_in_bytes": "available_in_bytes",
                        "total_in_bytes": "total_in_bytes"
                      },
                      "script": "params.available_in_bytes / params.total_in_bytes"
                    }
                  }
                }
              }
            },
            "size": 0
          }
        }
      }
    },
    "condition": {
      "type": "script",
      "status": "success",
      "met": false
    },
    "actions": []
  },
  "messages": []
}

```

// Results from just running the query:

> <https://gist.github.com/nhtrn/ed9f8ae97430f09db8be71cae563da18>

---

<div class="post-metadata">

**Author:** ![ntran](https://avatars.discourse-cdn.com/v4/letter/n/73ab20/32.png) [@ntran](https://discuss.elastic.co/u/ntran)\
**Post date:** [September 11, 2019, 12:22pm UTC](https://discuss.elastic.co/t/no-results-in-execution-output-watcher-elasticsearch/198539/2 "2019-09-11T12:22:48Z")

</div>

Hi everyone,

Has anyone experienced anything similar before?  
I would appreciate your feedback 🙂

---

<div class="post-metadata">

**Author:** ![ntran](https://avatars.discourse-cdn.com/v4/letter/n/73ab20/32.png) [@ntran](https://discuss.elastic.co/u/ntran)\
**Post date:** [September 15, 2019, 6:45am UTC](https://discuss.elastic.co/t/no-results-in-execution-output-watcher-elasticsearch/198539/3 "2019-09-15T06:45:20Z")

</div>

Hi everyone,

Following up on this, has anyone experienced something similar?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 16, 2019, 1:45pm UTC](https://discuss.elastic.co/t/no-results-in-execution-output-watcher-elasticsearch/198539/4 "2019-09-16T13:45:38Z")

</div>

please reread the output you shared, especially this part

```auto
"result": {
    "execution_time": "2019-09-08T05:59:05.686Z",
    "execution_duration": 4,
    "input": {
      "type": "search",
      "status": "success",
      "payload": {
        "_shards": {
          "total": 7,
          "failed": 0,
          "successful": 7,
          "skipped": 0
        },
        "hits": {
          "hits": [],
          "total": 0,
          "max_score": null
        }

```

this is the actual output from your search. Your search did not yield any results (a count of 0), so the condition very likely did not turn out to be true and thus no actions were triggered.

---

<div class="post-metadata">

**Author:** ![ntran](https://avatars.discourse-cdn.com/v4/letter/n/73ab20/32.png) [@ntran](https://discuss.elastic.co/u/ntran)\
**Post date:** [September 17, 2019, 7:35am UTC](https://discuss.elastic.co/t/no-results-in-execution-output-watcher-elasticsearch/198539/5 "2019-09-17T07:35:21Z")

</div>

Hi @spinscale

Thanks for the reply.  
I was wondering why then when I just run the `query` without the rest of the watcher, I get an executed output with aggregations?

Nhung

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 17, 2019, 2:10pm UTC](https://discuss.elastic.co/t/no-results-in-execution-output-watcher-elasticsearch/198539/6 "2019-09-17T14:10:55Z")

</div>

you would need to replace the `{{ctx.trigger.scheduled_time}}` time filtering part manually.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 15, 2019, 2:11pm UTC](https://discuss.elastic.co/t/no-results-in-execution-output-watcher-elasticsearch/198539/7 "2019-10-15T14:11:01Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
