# Webhook.host doesn't translate ctx.metadata values

**URL:** <https://discuss.elastic.co/t/webhook-host-doesnt-translate-ctx-metadata-values/66994>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [November 23, 2016, 2:40pm UTC](https://discuss.elastic.co/t/webhook-host-doesnt-translate-ctx-metadata-values/66994 "2016-11-23T14:40:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nielsoncr](https://avatars.discourse-cdn.com/v4/letter/n/c57346/32.png) [@nielsoncr](https://discuss.elastic.co/u/nielsoncr)\
**Post date:** [November 23, 2016, 2:40pm UTC](https://discuss.elastic.co/t/webhook-host-doesnt-translate-ctx-metadata-values/66994/1 "2016-11-23T14:40:32Z")

</div>

I have a multiple watches that perform a webhook action. I want to store the host in a ctx.metatdata field for flexibility in cases where the host may differ depending on installation parameters, but the {{ctx.metadata}} value isn't being translated on watch execution.

meta data look like this:

```
"metadata":
{
    "Host" : "myurl",
    "Authorization" : "myauth"
}

```

webhook like this:

```
    "webhook" :
      {
            "method" : "post",
            "scheme" : "https",
            "host" : "{{ctx.metadata.Host}}",
            "headers" : 
            {
                "Authorization": "Basic {{ctx.metadata.Authorization}}",
            },
       }

```

when the watch is executed I get this error

```
           "reason": "ElasticsearchException[Illegal character in authority at index 8: https://{{ctx.metadata.Host}}:443/rest/api/2/issue]; nested: URISyntaxException[Illegal character in authority at index 8: https://{{ctx.metadata.Host}}:443/rest/api/2/issue]; "

```

When host is hard coded everything works. The ctx.metadata.Authorization translation in the "headers" section occurs as expected so I can only assume the webhook.host field doesn't support ctx.metadata values. Can anyone confirm, or provide an alternative.

I'm using Elasticsearch version 2.1.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:** [November 23, 2016, 2:48pm UTC](https://discuss.elastic.co/t/webhook-host-doesnt-translate-ctx-metadata-values/66994/2 "2016-11-23T14:48:20Z")

</div>

Hey,

you are right. The host is not templatable right now, header, params and body are however. I do not have any alternative on top of my head right now, but we could make this templatable in the future.

--Alex

---

<div class="post-metadata">

**Author:** ![nielsoncr](https://avatars.discourse-cdn.com/v4/letter/n/c57346/32.png) [@nielsoncr](https://discuss.elastic.co/u/nielsoncr)\
**Post date:** [November 23, 2016, 3:20pm UTC](https://discuss.elastic.co/t/webhook-host-doesnt-translate-ctx-metadata-values/66994/3 "2016-11-23T15:20:20Z")

</div>

We would definitely use it. Where in the documentation could I have found this information? I looked around, but didn't find it.

---

<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:** [November 23, 2016, 3:28pm UTC](https://discuss.elastic.co/t/webhook-host-doesnt-translate-ctx-metadata-values/66994/4 "2016-11-23T15:28:28Z")

</div>

Hey,

the [webhook action attributes table](https://www.elastic.co/guide/en/watcher/2.4/actions.html#actions-webhook) lists which fields support templates

--Alex

---

<div class="post-metadata">

**Author:** ![nielsoncr](https://avatars.discourse-cdn.com/v4/letter/n/c57346/32.png) [@nielsoncr](https://discuss.elastic.co/u/nielsoncr)\
**Post date:** [November 23, 2016, 3:36pm UTC](https://discuss.elastic.co/t/webhook-host-doesnt-translate-ctx-metadata-values/66994/5 "2016-11-23T15:36:44Z")

</div>

Thanks -- I see the information now. When considering adding additional templating please include host port and scheme

---

<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:** [December 21, 2016, 3:36pm UTC](https://discuss.elastic.co/t/webhook-host-doesnt-translate-ctx-metadata-values/66994/6 "2016-12-21T15:36:55Z")

</div>

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