# Using context in trigger interval

**URL:** <https://discuss.elastic.co/t/using-context-in-trigger-interval/247495>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [September 4, 2020, 7:52am UTC](https://discuss.elastic.co/t/using-context-in-trigger-interval/247495 "2020-09-04T07:52:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Veenstra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_veenstra/32/47241_2.png) [@Mark\_Veenstra](https://discuss.elastic.co/u/Mark_Veenstra)\
**Post date:** [September 4, 2020, 7:52am UTC](https://discuss.elastic.co/t/using-context-in-trigger-interval/247495/1 "2020-09-04T07:52:26Z")

</div>

When I try to do the next:

```auto
{
  "trigger": {
    "schedule": {
      "interval": "{{ctx.metadata.config.interval}}s"
    }
  }
  "metadata": {
    "interval": 5
  }
}

```

It will not work and throws the error: `[parse_exception] could not parse [interval] schedule. could not parse [{{ctx.metadata.config.interval}}] as a [seconds] duration` while saving the watcher.  
I guess the `ctx` is also not available at that moment of saving. But is there a way to refer to the `metadata` to be used in the trigger interval?

---

<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:** [September 16, 2020, 10:07am UTC](https://discuss.elastic.co/t/using-context-in-trigger-interval/247495/2 "2020-09-16T10:07:20Z")

</div>

The interval schedule does not support reading a variable, you have to specify `5s` as a string or `5` as a value to represent seconds as a hardcoded value here.

Side note: The correct way to address that metadata value would be `{{ctx.metadata.interval}}`

---

<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:** [October 14, 2020, 10:07am UTC](https://discuss.elastic.co/t/using-context-in-trigger-interval/247495/3 "2020-10-14T10:07:50Z")

</div>

Closed on October 14, 2020, 10:07am UTC

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