# Watcher HTTP Input request

**URL:** <https://discuss.elastic.co/t/watcher-http-input-request/176101>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [April 9, 2019, 8:54pm UTC](https://discuss.elastic.co/t/watcher-http-input-request/176101 "2019-04-09T20:54:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmdm](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@dmdm](https://discuss.elastic.co/u/dmdm)\
**Post date:** [April 9, 2019, 8:54pm UTC](https://discuss.elastic.co/t/watcher-http-input-request/176101/1 "2019-04-09T20:54:55Z")

</div>

Is there a way to sort this on a field for example end\_time so that when I check this value ctx.payload.snapshots.0.state it will be the last snapshot that ran?

````auto
  "trigger": {
    "schedule": {
      "interval": "1h"
    }
  },
  "input": {
    "http": {
      "request": {
        "scheme": "http",
        "host": "localhost",
        "port": 9200,
        "method": "get",
        "path": "/_snapshot/s3_repository/_all",
        "headers": {}
      }
    }
  },
   "condition": {
    "script": {
      "source": "if (ctx.payload.snapshots.0.state == 'FAILED') { return true; } return false;",
      "lang": "painless",
      "params": {
        "threshold": 0
      }
    }
  },
  "actions": {
    "pagerduty": {
      
      "webhook": {
        "scheme": "https",
        "host": "events.pagerduty.com",
        "port": 443,
        "method": "post",
        "path": "/v2/enqueue",
        "params": {},
        "headers": {
          "Content-type": "application/json"
        },
        "body": "{\"payload\":{\"summary\": \"The {{ctx.payload.snapshots.0.snapshot}} \",\"source\": \"elasticsearch\",\"severity\": \"critical\"}, \"routing_key\": \"${routkey}\", \"event_action\": \"trigger\", \"client\": \"${POD}\",\"dedup_key\":\"TRACKSCH001\"}"
      }
    }
  }
}```
````

---

<div class="post-metadata">

**Author:** ![dmdm](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@dmdm](https://discuss.elastic.co/u/dmdm)\
**Post date:** [April 9, 2019, 8:55pm UTC](https://discuss.elastic.co/t/watcher-http-input-request/176101/2 "2019-04-09T20:55:42Z")

</div>

or a way to get the last value of the array somehow without a sort?

---

<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:** [April 11, 2019, 2:01pm UTC](https://discuss.elastic.co/t/watcher-http-input-request/176101/3 "2019-04-11T14:01:36Z")

</div>

can you try `/_snapshot/s3_repository/_current`?

--Alex

---

<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 9, 2019, 2:01pm UTC](https://discuss.elastic.co/t/watcher-http-input-request/176101/4 "2019-05-09T14:01:40Z")

</div>

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