# Logstash processing messages out of order

**URL:** <https://discuss.elastic.co/t/logstash-processing-messages-out-of-order/196843>\
**Category:** Logstash\
**Created:** [August 26, 2019, 9:27pm UTC](https://discuss.elastic.co/t/logstash-processing-messages-out-of-order/196843 "2019-08-26T21:27:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sous\_Lesquels](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sous_lesquels/32/41843_2.png) [@Sous\_Lesquels](https://discuss.elastic.co/u/Sous_Lesquels)\
**Post date:** [August 26, 2019, 9:27pm UTC](https://discuss.elastic.co/t/logstash-processing-messages-out-of-order/196843/1 "2019-08-26T21:27:45Z")

</div>

I have a long config that looks at several types of messages - very similar to the canonical examples given at the [aggregate plugin docs page](https://www.elastic.co/guide/en/logstash/current/plugins-filters-aggregate.html), Example 1, here's the gist:

```auto
filter {

  grok {
    match => { ... }
    add_field => { 'type' => 'type_a' }
  }

  if (! [type]) {
    grok {
      match => { ... }
      add_field => { 'type' => 'type_b' }
    }
  }

  if (! [type]) {
    grok {
      match => { ... }
      add_field => { 'type' => 'type_c' }
    }
  }

  if ([type] == 'type_b') {
    aggregate {
      task_id => '...'
      map_action => 'create'
      code => "..."
    }

    drop {}
  }

  if ([type] == 'type_c') {
    aggregate {
      task_id => '...'
      end_of_task => true
      timeout => 60
      map_action => 'update'
      code => "..."
    }
  }

}

```

The config seems to be working OK otherwise, i.e. it picks up the correct types and other fields as needed from what I am seeing.

I've confirmed I have one worker:

```auto
Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>1, "pipeline.batch.size"=>1000, "pipeline.batch.delay"=>50, "pipeline.max_inflight"=>1000, :thread=>"#<Thread:0x754f9f28 run>"}

```

However, I still see it processing out of order. E.g. for a file such as:

```auto
type A
type B
type C

```

where `type B` and `type C` are aggregated as start / end events per the above config, I see it processing in this order:

```auto
type C
type A

```

which completely breaks the things downstream.

What should I be doing differently or what else can I try to troubleshoot or solve this?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [August 26, 2019, 10:27pm UTC](https://discuss.elastic.co/t/logstash-processing-messages-out-of-order/196843/2 "2019-08-26T22:27:49Z")

</div>

In logstash.yml, set

```
pipeline.java_execution: false

```

There is a PR to fix [this](https://github.com/elastic/logstash/issues/10938) issue in-flight.

---

<div class="post-metadata">

**Author:** ![Sous\_Lesquels](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sous_lesquels/32/41843_2.png) [@Sous\_Lesquels](https://discuss.elastic.co/u/Sous_Lesquels)\
**Post date:** [September 11, 2019, 7:28pm UTC](https://discuss.elastic.co/t/logstash-processing-messages-out-of-order/196843/3 "2019-09-11T19:28:14Z")

</div>

@Badger Thanks, changed that:

```auto
Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>1, "pipeline.batch.size"=>1000, "pipeline.batch.delay"=>50}

```

but I'm still getting events out of order sometimes. Any other things I can try?

---

<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:** [October 9, 2019, 7:40pm UTC](https://discuss.elastic.co/t/logstash-processing-messages-out-of-order/196843/4 "2019-10-09T19:40:48Z")

</div>

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