# \[ALERTING\] Malfored URLs when trying to create a chained input watch

**URL:** <https://discuss.elastic.co/t/alerting-malfored-urls-when-trying-to-create-a-chained-input-watch/101932>\
**Category:** Elasticsearch\
**Created:** [September 27, 2017, 6:26am UTC](https://discuss.elastic.co/t/alerting-malfored-urls-when-trying-to-create-a-chained-input-watch/101932 "2017-09-27T06:26:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anishm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anishm/32/28796_2.png) [@anishm](https://discuss.elastic.co/u/anishm)\
**Post date:** [September 27, 2017, 6:26am UTC](https://discuss.elastic.co/t/alerting-malfored-urls-when-trying-to-create-a-chained-input-watch/101932/1 "2017-09-27T06:26:53Z")

</div>

I am trying to create a chained input for watcher that involves reading response from an API and making another another API call to the service mentioned in the body of the first request. Here's what the input looks like:

```
"inputs": [
        {
          "first": {
            "http": {
              "request": {
                "host": "localhost",
                "port": 1200,
                "path": "/status/service/myservice",
                "params": {
                  "somevar": "somevalue"
                }
              }
            }
          }
        },
        {
          "second": {
            "http": {
              "request": {
                "url": "http://{{ctx.payload.first.data[0].ip}}:{{ctx.payload.first.data.port}}/somepath/inservice/status"
              }
            }
          }
        }

```

But when trying to create the watch, I get the error:

```
{
  "error": {
    "root_cause": [
      {
        "type": "parse_exception",
        "reason": "Malformed URL ["http://{{ctx.payload.first.data[0].ip}}:{{ctx.payload.first.data.port}}/somepath/inservice/status]"
      }
    ],
    "type": "parse_exception",
    "reason": "could not parse [http] input for watch [second]. failed to parse http request template",
    "caused_by": {
      "type": "parse_exception",
      "reason": "Malformed URL ["http://{{ctx.payload.first.data[0].ip}}:{{ctx.payload.first.data.port}}/somepath/inservice/status]"
    }
  },
  "status": 400
}

```

Also, I see that String values are not allowed in the `request.port` and hence the long format for definition of the http request will also not work.  
Is this not supported in X-Pack Alerting even in the latest versions? Or I have to upgrade?  
Elasticsearch Version: 5.4.2

---

<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:** [October 2, 2017, 1:09pm UTC](https://discuss.elastic.co/t/alerting-malfored-urls-when-trying-to-create-a-chained-input-watch/101932/2 "2017-10-02T13:09:47Z")

</div>

The `url` field from the request is not templateable, you would need to use the `host`, `port`, `path` and `port` fields, which are.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![anishm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anishm/32/28796_2.png) [@anishm](https://discuss.elastic.co/u/anishm)\
**Post date:** [October 3, 2017, 6:57am UTC](https://discuss.elastic.co/t/alerting-malfored-urls-when-trying-to-create-a-chained-input-watch/101932/3 "2017-10-03T06:57:39Z")

</div>

I think even the port field is not templatable. When I do,

```auto
{
  "host": "localhost",
   "port": "{{ctx.payload.first.data.port}}",
   "path": "/status/service/myservice",
   "params": {
     "somevar": "somevalue"
    }
}

```

I get a validation error from Elasticsearch saying `port` cannot be a string. Also, just using `"port": {{ctx.payload.first.data.port}}` is bad json. I am not sure how to proceed with this.

---

<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:** [October 6, 2017, 7:48am UTC](https://discuss.elastic.co/t/alerting-malfored-urls-when-trying-to-create-a-chained-input-watch/101932/4 "2017-10-06T07:48:18Z")

</div>

Hey,

indeed, I stand corrected here. I just checked the source and only `path`, headers, params and the body are templetable for now.

--Alex

---

<div class="post-metadata">

**Author:** ![anishm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anishm/32/28796_2.png) [@anishm](https://discuss.elastic.co/u/anishm)\
**Post date:** [October 6, 2017, 12:54pm UTC](https://discuss.elastic.co/t/alerting-malfored-urls-when-trying-to-create-a-chained-input-watch/101932/5 "2017-10-06T12:54:17Z")

</div>

This actually limits the use of chained input. Is there a place where I can raise this issue?

---

<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:** [November 3, 2017, 12:54pm UTC](https://discuss.elastic.co/t/alerting-malfored-urls-when-trying-to-create-a-chained-input-watch/101932/6 "2017-11-03T12:54:30Z")

</div>

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