Skip to content

[Website]: Template example does not work #3696

@felipeavilis

Description

@felipeavilis

Type of issue

Other

What documentation page is affected

https://www.elastic.co/docs/explore-analyze/alerts-cases/watcher/input-http#_using_templates_2

What happened?

The value {{ctx.trigger.triggered_time}}||-5m of from in body does not work. {{ctx.trigger.triggered_time}} returns a string and cannot do the time math.

This happens because date math expressions only work in specific Elasticsearch contexts (like index names and date range queries), not in arbitrary mustache template positions.

To solve this i had to create a Transform Script.

{
  "transform": {
    "script": {
      "source": "ctx.payload.calculated_time = ZonedDateTime.parse(ctx.trigger.triggered_time).minusMinutes(5)",
      "lang": "painless"
    }
  }
}

Additional info

No response

Metadata

Metadata

Labels

Team:ExperienceIssues owned by the Experience Docs Teamcommunitysource:webIssues originating from the elastic.co docs

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions