# Update field value based on reference variable

**URL:** <https://discuss.elastic.co/t/update-field-value-based-on-reference-variable/274826>\
**Category:** Logstash\
**Created:** [June 3, 2021, 6:59am UTC](https://discuss.elastic.co/t/update-field-value-based-on-reference-variable/274826 "2021-06-03T06:59:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![san2597](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/san2597/32/89746_2.png) [@san2597](https://discuss.elastic.co/u/san2597)\
**Post date:** [June 3, 2021, 6:59am UTC](https://discuss.elastic.co/t/update-field-value-based-on-reference-variable/274826/1 "2021-06-03T06:59:23Z")

</div>

Using Logstash, I'm parsing a log file that contains a timestamp value every time a new process starts. Each process starts and logs its own run time starting from 0 to the time the process completes. I'm trying to visualize this in Kibana, and would like to be able to update the process time to the real-time timestamp being logged for that process.

Sample Input:

```
12:00:00 Process A starts: 
     0:00:01 Step 1
     0:00:04 Step 2
     ........
     0:10:01 Process Ends
%Random Log lines of no interest
12:10:05 Process B starts:
     0:00:01 Step 1
     0:00:04 Step 2
     ........
     0:10:01 Process Ends
.........

```

I'd like to parse this such that each timestamp is updated with the starting timestamp of the process.

Sample Output:

```
12:00:00 Process A starts: 
     12:00:01 Step 1
     12:00:04 Step 2
     ........
     12:10:01 Process Ends
%Random Log lines of no interest
12:10:05 Process B starts:
     12:10:06 Step 1
     12:10:09 Step 2
     ........
     12:20:06 Process Ends
.........

```

If this can be done either in Logstash or Elasticsearch that would be really helpful.

---

<div class="post-metadata">

**Author:** ![Cad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cad/32/86661_2.png) [@Cad](https://discuss.elastic.co/u/Cad)\
**Post date:** [June 3, 2021, 7:52am UTC](https://discuss.elastic.co/t/update-field-value-based-on-reference-variable/274826/2 "2021-06-03T07:52:19Z")

</div>

Hi,

Take a look to the [aggregate filter](https://www.elastic.co/guide/en/logstash/current/plugins-filters-aggregate.html). I think it's a good choice in your case.

Cad.

---

<div class="post-metadata">

**Author:** ![san2597](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/san2597/32/89746_2.png) [@san2597](https://discuss.elastic.co/u/san2597)\
**Post date:** [June 4, 2021, 12:04am UTC](https://discuss.elastic.co/t/update-field-value-based-on-reference-variable/274826/3 "2021-06-04T00:04:40Z")

</div>

Hi Cad,  
I could use the aggregate filter, but it works by aggregating messages with common field i.e task id. Would that mean that my process logs would have to contain a common field to aggregate?

---

<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 2, 2021, 12:05am UTC](https://discuss.elastic.co/t/update-field-value-based-on-reference-variable/274826/4 "2021-07-02T00:05:37Z")

</div>

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