# Referencing a simple input from a different input in a watcher

**URL:** https://discuss.elastic.co/t/referencing-a-simple-input-from-a-different-input-in-a-watcher/157401
**Category:** Elasticsearch
**Tags:** elastic-stack-alerting
**Created:** [November 19, 2018, 4:39pm UTC](https://discuss.elastic.co/t/referencing-a-simple-input-from-a-different-input-in-a-watcher/157401 "2018-11-19T16:39:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![yesman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yesman/32/37389_2.png) [@yesman](https://discuss.elastic.co/u/yesman)
#### Post date: [November 19, 2018, 4:39pm UTC](https://discuss.elastic.co/t/referencing-a-simple-input-from-a-different-input-in-a-watcher/157401/1 "2018-11-19T16:39:27Z")

</div>

Howdy Y'all,

My team is trying to construct a watcher that uses the strings defined in the simple input section and places them into the search input section so I can rapidly create multiple watchers by only having to modify the simple input section. For some additional context, we want to do this because we have to create a lot of watchers for different policies, and each watcher will have many different inputs, so being able to do this would save us a lot of time especially if we need to change the process in the future.

In my JSON, I pass in the simple inputs into the parameters of my search template but it interprets it literally as a string ("{{ctx.payload.first.process}}" rather than "java"). How can I force it to substitute the variable as the query? Is what I am trying to do even possible?

Below is example JSON of my watcher where I try and pass in the simple inputs:

//my Watcher JSON

```auto
"input" : {
    "chain": {
        "inputs": [
        {
            "first": {
                "simple": {
                    "process": "java"
                }
            }
        },
        {   
            "second": {
                "search": {
                    "request": {
                        "search_type": "query_then_fetch",
                        "indices": ["metricbeat-2018-11-13"],
                        "types": ,
                        "template": {
                        "id": "Template",
                        "params": {
                            "ctx_payload_first_process": "{{ctx.payload.first.process}}"
                            }
                        }
                    }   
                }
            }
        }]
    }
}

```

Once again, under params, it interprets "ctx\_payload\_first\_process" as the literal string  
"{{ctx.payload.first.process}}" and not the actual process "java" that I have defined in the simple input when I attempt to reference this data later. Any help/information is greatly appreciated!

Many thanks,

Yes Man

---

<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 27, 2018, 8:31am UTC](https://discuss.elastic.co/t/referencing-a-simple-input-from-a-different-input-in-a-watcher/157401/2 "2018-11-27T08:31:09Z")

</div>

Hey,

unfortunately it is not always clear, when a field is treated as a mustache template or when it is just treated as a string - which is the case here.

A workaround to this would be to use a search with a `body`, as the body is treated as a mustache template, so you can use the `{{ctx.payload.first.process}}` in there.

--Alex

---

<div class="post-metadata">

### Author: ![yesman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yesman/32/37389_2.png) [@yesman](https://discuss.elastic.co/u/yesman)
#### Post date: [November 27, 2018, 9:42pm UTC](https://discuss.elastic.co/t/referencing-a-simple-input-from-a-different-input-in-a-watcher/157401/3 "2018-11-27T21:42:27Z")

</div>

Hey @spinscale,

Thanks for the response, using a search with a body fixed our issues!

Much appreicated,

Yes Man

---

<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 25, 2018, 9:42pm UTC](https://discuss.elastic.co/t/referencing-a-simple-input-from-a-different-input-in-a-watcher/157401/4 "2018-12-25T21:42:37Z")

</div>

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