# Define global variables for the Kibana watches

**URL:** <https://discuss.elastic.co/t/define-global-variables-for-the-kibana-watches/155473>\
**Category:** Kibana\
**Tags:** elastic-stack-alerting\
**Created:** [November 6, 2018, 1:10am UTC](https://discuss.elastic.co/t/define-global-variables-for-the-kibana-watches/155473 "2018-11-06T01:10:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Preetiv](https://avatars.discourse-cdn.com/v4/letter/p/a698b9/32.png) [@Preetiv](https://discuss.elastic.co/u/Preetiv)\
**Post date:** [November 6, 2018, 1:10am UTC](https://discuss.elastic.co/t/define-global-variables-for-the-kibana-watches/155473/1 "2018-11-06T01:10:15Z")

</div>

I have several Kibana watches using the same variables in their query, e.g. `k8s_env` in this example watch query

```auto
          "must": [
            {
              "query_string": {
                "query": "error" AND k8s_env:(\”abc-prod\" OR \"def-prod\" OR \”xyz-prod\")
                "analyze_wildcard": true
              }
            }, ….

```

If I need to change the variable `k8s_env` anytime to make changes to the environments, I need to change the body of each watch and I have too many of those watches.

I am looking to define a global variable ‘k8s\_env’ somewhere, so that it is available to the watches and hence when our environments change, I need to make the change only in one place in the config file and not all the watches which I do now.  
So my questions are:

- Where do I define a global variable so that it is available to the watches?
- Is there a PUT API that I can use to PUT or define some variables so the watches can access them?

We deploy elastic search and the kibana watches using ansible.

---

<div class="post-metadata">

**Author:** ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)\
**Post date:** [November 8, 2018, 12:30am UTC](https://discuss.elastic.co/t/define-global-variables-for-the-kibana-watches/155473/2 "2018-11-08T00:30:45Z")

</div>

This kind of global variable functionality would need to be added to Elasticsearch. Could you please file an [enhancement request on the ES repo](https://github.com/elastic/elasticsearch/issues/new)?

Thanks,  
CJ

---

<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 6, 2018, 12:31am UTC](https://discuss.elastic.co/t/define-global-variables-for-the-kibana-watches/155473/3 "2018-12-06T00:31:01Z")

</div>

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