Watcher alert for index sizes

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.

{
  "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}}"
        }
      }
    }
  }
}

change 214748364800 to 214748364800L

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