# Getting the latest transform trigger time in a continuous transform

**URL:** <https://discuss.elastic.co/t/getting-the-latest-transform-trigger-time-in-a-continuous-transform/327420>\
**Category:** Elasticsearch\
**Tags:** transforms\
**Created:** [March 10, 2023, 7:49am UTC](https://discuss.elastic.co/t/getting-the-latest-transform-trigger-time-in-a-continuous-transform/327420 "2023-03-10T07:49:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cwwongaz](https://avatars.discourse-cdn.com/v4/letter/c/82dd89/32.png) [@cwwongaz](https://discuss.elastic.co/u/cwwongaz)\
**Post date:** [March 10, 2023, 7:49am UTC](https://discuss.elastic.co/t/getting-the-latest-transform-trigger-time-in-a-continuous-transform/327420/1 "2023-03-10T07:49:03Z")

</div>

Hi, I am running a continuous transform at a `15-minute frequency` to transform the data from `index_A` to `index_B`.

In the transform, I have set a `120s sync delay` time to avoid missing the latest data. However, in the aggregation scripts, I have a function that would require finding out the time elapsed between the document `@timestamp` and the trigger time of the transformation.

That is, suppose the continuous transformation triggers at a time `T`, I would like to get the time `T - doc[@timestamp].value` in the Scripted metric aggregation i.e. `init_script` / `map_script` / `reduce_script`

My questions are:

1. As I cannot find a way to get the transformation triggers time `T`, I am currently using the `System.currentTimeMillis()` as the time `T` to get the time elapsed, however, I am concerned that the possible `sync delay` time will cause a difference in the script.

2. Is there any way to get the transformation triggers time `T` inside the Scripted metric aggregation? I have seen that the `time_upper_bound_millis` from the transform page, is this time ``time\_upper\_bound\_millis` equal to the transformation triggers time I need? If it is, is there any way to get it in the Scripted metric aggregation?

Attached is the transform information.

```auto
{
  "id": "transform script",
  "version": "7.14.2",
  "create_time": -,
  "source": {
    "index": [
      "index_A"
    ],
    "query": {
      "bool": {
        "filter": [
          {
            "range": {
              "@timestamp": {
                "gte": "now-15m"
              }
            }
          }
        ]
      }
    }
  },
  "dest": {
    "index": "index_B",
    "pipeline": ""
  },
  "frequency": "15m",
  "sync": {
    "time": {
      "field": "@timestamp",
      "delay": "120s"
    }
  },
  "pivot": {
    "group_by": {
      
      }
    },
    "aggregations": {
      "@timestamp": {
        "max": {
          "field": "@timestamp"
        }
      },
      "script_field": {
        "scripted_metric": {
          "combine_script": "return state",
          "init_script": {
            "id": "some_init_script"
          },
          "map_script": {
            "id": "some_map_script"
          },
          "params": {
            
          },
          "reduce_script": {
            "id": "some_reduce_script"
          }
        }
      }
    }
  },
  "description": "DEMO",
  "settings": {
    "max_page_search_size": 10000
  }
}

```

---

<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:** [April 7, 2023, 7:49am UTC](https://discuss.elastic.co/t/getting-the-latest-transform-trigger-time-in-a-continuous-transform/327420/2 "2023-04-07T07:49:16Z")

</div>

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