# Watcher multiple condition script error

**URL:** <https://discuss.elastic.co/t/watcher-multiple-condition-script-error/269263>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-monitoring, elastic-stack-alerting\
**Created:** [April 5, 2021, 7:37pm UTC](https://discuss.elastic.co/t/watcher-multiple-condition-script-error/269263 "2021-04-05T19:37:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Smit108](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@Smit108](https://discuss.elastic.co/u/Smit108)\
**Post date:** [April 5, 2021, 7:37pm UTC](https://discuss.elastic.co/t/watcher-multiple-condition-script-error/269263/1 "2021-04-05T19:37:33Z")

</div>

HI  
i'm trying to set cluster health with condition in script but getting error while i'm execute it.

```auto
    {
    “trigger”: {
    “schedule”: {
    “interval”: “10s”
    }
    },
    “input”: {
    “http”: {
    “request”: {
    “scheme”: “https”,
    “host”: “hostname”,
    “port”: XXX,
    “method”: “get”,
    “path”: “/_cluster/health”,
    “params”: {},
    “headers”: {},
    “auth”: {
    “basic”: {
    “username”: “XXXXX”,
    “password”: “XXXX”
    }
    }
    }
    }
    },
    “condition”: {
    “script”:
    {
    “source”: “return ctx.payload.unassigned_shards > 0 || ctx.payload.status !=green “,
    “lang”: “painless”
    }
    },
    “actions”: {
    “my-logging-action”: {
    “logging”: {
    “level”: “info”,
    “text”: “Cluster {{ctx.payload.cluster_name}} have not NOT been green for more than {{ctx.metadata.not_green_secs}}s: {{#ctx.payload._value}}{{cluster_id}}-{{cluster_state}}{{/ctx.payload._value}} . & unassigned_shards {{ctx.payload.unassigned_shards}}”
    }
    }
    }
    }

```

---

<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:** [May 3, 2021, 7:37pm UTC](https://discuss.elastic.co/t/watcher-multiple-condition-script-error/269263/2 "2021-05-03T19:37:46Z")

</div>

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