# Logstash - adding shared field to link related logs

**URL:** <https://discuss.elastic.co/t/logstash-adding-shared-field-to-link-related-logs/68933>\
**Category:** Logstash\
**Created:** [December 13, 2016, 8:05pm UTC](https://discuss.elastic.co/t/logstash-adding-shared-field-to-link-related-logs/68933 "2016-12-13T20:05:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![colm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colm/32/51130_2.png) [@colm](https://discuss.elastic.co/u/colm)\
**Post date:** [December 13, 2016, 8:05pm UTC](https://discuss.elastic.co/t/logstash-adding-shared-field-to-link-related-logs/68933/1 "2016-12-13T20:05:13Z")

</div>

i'm processing logs from multiple voice switches with logstash 5.0.1.

the logs are often related to other logs by "call\_ids". i extract these into an array:

> event.set("call\_ids", event.get("message").scan(/\s+Z\S+\s+(\S+)@\S+/).flatten)

a master record will usually be present and will have a few of these:

> LOG1 - call\_ids:31967-CJ-0679798b-69dbbb183, 27368-YT-06797982-6342ccc83, 31810-JE-0679797d-69dfcbed0, 76838398-3690563729-694540 ...

most of these call\_ids will appear in one other related log which is received within a minute of the others:

> LOG2 - call\_ids:31967-CJ-0679798b-69dbbb183  
> LOG3 - call\_ids:27368-YT-06797982-6342ccc83  
> LOG4 - call\_ids:31810-JE-0679797d-69dfcbed0

however the master log will often appear after the other device logs.

i would like to add a field to each of these events which links them together (call\_id\_link).

however, i think i need to make use of global/class variables to do so and i have no experience in ruby.

do you guys have any advice on how to proceed?

note that i tried using the aggregate filter using call\_ids as task\_ids but could not get this work where the master log appears after the other logs.

thanks for your help,

colm

---

<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:** [January 10, 2017, 8:05pm UTC](https://discuss.elastic.co/t/logstash-adding-shared-field-to-link-related-logs/68933/2 "2017-01-10T20:05:14Z")

</div>

Closed on January 10, 2017, 8:05pm UTC

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