# Offenders in Watcher

**URL:** <https://discuss.elastic.co/t/offenders-in-watcher/133678>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [May 29, 2018, 12:28pm UTC](https://discuss.elastic.co/t/offenders-in-watcher/133678 "2018-05-29T12:28:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jasonespo](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@Jasonespo](https://discuss.elastic.co/u/Jasonespo)\
**Post date:** [May 29, 2018, 12:28pm UTC](https://discuss.elastic.co/t/offenders-in-watcher/133678/1 "2018-05-29T12:28:50Z")

</div>

Hi all,

Would it be possible to run the following query on a regular basis perhaps in a watcher? And push the output via a webhook?

GET \_cat/indices/\*?v&s=store.size&bytes=k&format=json

Regards,

Jason

---

<div class="post-metadata">

**Author:** ![tylersmalley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tylersmalley/32/8833_2.png) [@tylersmalley](https://discuss.elastic.co/u/tylersmalley)\
**Post date:** [May 29, 2018, 10:37pm UTC](https://discuss.elastic.co/t/offenders-in-watcher/133678/2 "2018-05-29T22:37:44Z")

</div>

I don't see why not. You could also just write a script and create a cronjob.

---

<div class="post-metadata">

**Author:** ![Jasonespo](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@Jasonespo](https://discuss.elastic.co/u/Jasonespo)\
**Post date:** [May 30, 2018, 10:18am UTC](https://discuss.elastic.co/t/offenders-in-watcher/133678/3 "2018-05-30T10:18:20Z")

</div>

Hi, this is what I have so far:

```
{
      "trigger": {
        "schedule": {
          "interval": "2m"
        }
      },
      "input": {
        "http": {
          "request": {
            "scheme": "http",
            "host": "NotReal.eu-west-1.aws.found.io",
            "port": 9200,
            "method": "GET",
            "path": "_cat/indices/tid*?v&s=store.size&bytes=k&format=json",
            "params": {},
            "headers": {},
            "auth": {
              "basic": {
                "username": "Hi",
                "password": "NotReal"
              }
            }
          }
        }

      },
  "actions": {
    "web_hook": {
      "webhook": {
        "scheme": "https",
        "host": "NotReal.NotReal.com",
        "port": 443,
        "method": "post",
        "path": "/private/staging/alert/create",
      
        "headers": {
          "x-api-key": "NotReal"
         },
        "body": "{{#toJson}}ctx.payload.offenders{{/toJson}}"
      }
    }
  },
  "throttle_period_in_millis": 120000
}

```

There is no condition so the action will always activate.

The webhook works and outputs "{}" as there is no payload. How would I get the payload to be the result of my GET query?

Appreciate your assistance,

Jason

---

<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:** [June 5, 2018, 8:14am UTC](https://discuss.elastic.co/t/offenders-in-watcher/133678/5 "2018-06-05T08:14:39Z")

</div>

can you include the output of the [execute watch API](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/watcher-api-execute-watch.html) here please so we can further debug this. I do not see an immediate reason why this should not work.

---

<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:** [July 3, 2018, 8:14am UTC](https://discuss.elastic.co/t/offenders-in-watcher/133678/6 "2018-07-03T08:14:41Z")

</div>

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