# Are formatters available in input Mustache templates?

**URL:** <https://discuss.elastic.co/t/are-formatters-available-in-input-mustache-templates/44561>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [March 16, 2016, 2:13pm UTC](https://discuss.elastic.co/t/are-formatters-available-in-input-mustache-templates/44561 "2016-03-16T14:13:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![beckerdo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/beckerdo/32/8355_2.png) [@beckerdo](https://discuss.elastic.co/u/beckerdo)\
**Post date:** [March 16, 2016, 2:13pm UTC](https://discuss.elastic.co/t/are-formatters-available-in-input-mustache-templates/44561/1 "2016-03-16T14:13:21Z")

</div>

Our Elasticsearch instance has indexes that are named based on the date. For example "cal-root-2016-03-15", "cal-root-2016-03-16", etc.

I'd like to be able to use date formatting in Mustache templates to create the path on the input http clause.

For example, this unformatted Mustache template works in input http:

> ```
> "request": {
> "host": "localhost",
> "method": "post",
> "path": "/cal-root-{{ctx.execution_time}}/logs/_search",
> "params": {
> "search_type": "count"
> },
> "body": {...}
> }
> 
> ```

To produce this kind of path for a put request path:

> ` "path": "/cal-root-2016-03-16T14:08:51.720Z/logs/_search",`

I would like to be able to do this formatted Mustache template in input http:

> ```
> "request": {
> "host": "localhost",
> "method": "post",
> "path": "/cal-root-{{dateFormat ctx.execution_time format=\"TTTT-mm-DD\"}}/logs/_search",
> "params": {
> "search_type": "count"
> },
> "body": {...}
> }
> 
> ```

This would produce the desired formatted put request path

> ` "path": "/cal-root-2016-03-16/logs/_search",`

Is some sort of date formatting available on the Mustache templates in Watcher?

Thanks, beckerdo

---

<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:** [March 17, 2016, 12:29pm UTC](https://discuss.elastic.co/t/are-formatters-available-in-input-mustache-templates/44561/2 "2016-03-17T12:29:31Z")

</div>

Hey,

formatters are not supported. A workaround for your problem might be to not try to have any date logic in your watch, but just use an alias, that points to the currently active index and update this either using a watch during midnight or a tool like curator.

--Alex

---

<div class="post-metadata">

**Author:** ![skearns](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/skearns/32/125945_2.png) [@skearns](https://discuss.elastic.co/u/skearns)\
**Post date:** [March 17, 2016, 9:33pm UTC](https://discuss.elastic.co/t/are-formatters-available-in-input-mustache-templates/44561/3 "2016-03-17T21:33:32Z")

</div>

It sounds like you could also use the [date math in index names](https://www.elastic.co/guide/en/elasticsearch/reference/current/date-math-index-names.html) support in Elasticsearch to achieve this?

---

<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:** [July 6, 2017, 1:46pm UTC](https://discuss.elastic.co/t/are-formatters-available-in-input-mustache-templates/44561/4 "2017-07-06T13:46:17Z")

</div>


