# Watcher alert for index sizes

**URL:** <https://discuss.elastic.co/t/watcher-alert-for-index-sizes/305633>\
**Category:** Kibana\
**Tags:** elastic-stack-alerting, painless\
**Created:** [May 25, 2022, 5:42pm UTC](https://discuss.elastic.co/t/watcher-alert-for-index-sizes/305633 "2022-05-25T17:42:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![venkatkumar229](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/venkatkumar229/32/104663_2.png) [@venkatkumar229](https://discuss.elastic.co/u/venkatkumar229)\
**Post date:** [May 25, 2022, 5:42pm UTC](https://discuss.elastic.co/t/watcher-alert-for-index-sizes/305633/1 "2022-05-25T17:42:52Z")

</div>

Hi Team,

I am trying to create an alert when any one of the index size crosses 200GB. I have created a watcher like below but i am getting an compile error not sure what was wrong. Could you please help me with this.

```auto
{
  "trigger": {
    "schedule": {
      "interval": "30m"
    }
  },
"input" : {
  "http" : {
    "request" : {
      "scheme": "http",
      "host" : "localhost",
      "port" : 9200,
      "path" : "_all/_stats/store",
      "params" : {
        "human" : "true"
      }
    }
  }
},
  "condition": {
    "script": {
      "source": """
ctx.payload.indices.entrySet().stream().filter(e-> e.value.total.store.size_in_bytes > 214748364800).count() > 0
""",
      "lang": "painless"
    }
  },
    "transform": {
    "script": {
      "source": """
        return [
          'only_ones': ctx.payload.indices.entrySet().stream()
		  .filter(e-> e.value.total.store.size_in_bytes > 214748364800).map(e-> ['key': e.key, 'value': e.value.total.store.size_in_bytes]).collect(Collectors.toList())
          ]
      """,
      "lang": "painless"
    }
  },
    "actions": {
    "send_email": {
      "email": {
        "profile": "standard",
        "to": [
          "someemail@domainname"
        ],
        "subject": "index size alert",
        "body": {
          "html": "{{#ctx.payload.only_ones}}{{key}}{{value}}{{/ctx.payload.only_ones}}"
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![richcollier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richcollier/32/115035_2.png) [@richcollier](https://discuss.elastic.co/u/richcollier)\
**Post date:** [May 31, 2022, 4:42pm UTC](https://discuss.elastic.co/t/watcher-alert-for-index-sizes/305633/2 "2022-05-31T16:42:35Z")

</div>

change `214748364800` to `214748364800L`

---

<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:** [June 28, 2022, 4:42pm UTC](https://discuss.elastic.co/t/watcher-alert-for-index-sizes/305633/3 "2022-06-28T16:42:51Z")

</div>

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