# Conditional Problem during log aggregation

**URL:** <https://discuss.elastic.co/t/conditional-problem-during-log-aggregation/112445>\
**Category:** Logstash\
**Created:** [December 19, 2017, 2:08pm UTC](https://discuss.elastic.co/t/conditional-problem-during-log-aggregation/112445 "2017-12-19T14:08:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simon\_Devineau](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simon_devineau/32/25797_2.png) [@Simon\_Devineau](https://discuss.elastic.co/u/Simon_Devineau)\
**Post date:** [December 19, 2017, 2:08pm UTC](https://discuss.elastic.co/t/conditional-problem-during-log-aggregation/112445/1 "2017-12-19T14:08:15Z")

</div>

Hello everyone,

I am writing about a conditional problem I have.  
I am trying to aggregate Jenkins logs line using  
[https://www.elastic.co/guide/en/logstash/current/plugins-filters-aggregate.html#plugins-filters-aggregate-example1](https://www.elastic.co/guide/en/logstash/current/plugins-filters-aggregate.html#plugins-filters-aggregate-example1)

As the Example #1, I want to use a conditional based on the fact the the first message starts with 'Started by'  
I follow this tutorial : [https://www.elastic.co/guide/en/logstash/current/config-examples.html#using-conditionals](https://www.elastic.co/guide/en/logstash/current/config-examples.html#using-conditionals)

So I did that

```
  if("Started by" in [message] ) {
     aggregate {
       task_id => "%{@buildTimestamp}"
       code => "map['message1']=event.get('message')"
       map_action => "create"
       add_field => { "startAgregation" => "yes" } #for debug purpose
     }
  }else{
    mutate {
       add_field => { "startAgregation" => "no" } #for debug purpose
        }
 }

```

As it did not worked, I tried  
`if([message] =~ "Started by" )`  
Then  
`if([message] =~ /^Started by.*/ )`

None of thus worked.  
But when I tried the whole message  
`if("Started by user DEVINEAU Simon" in [message] )`  
Then it worked.

Do you have any idea ?

---

<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 16, 2018, 2:08pm UTC](https://discuss.elastic.co/t/conditional-problem-during-log-aggregation/112445/2 "2018-01-16T14:08:43Z")

</div>

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