# Logstash Filter to combine patterns together

**URL:** <https://discuss.elastic.co/t/logstash-filter-to-combine-patterns-together/182184>\
**Category:** Logstash\
**Created:** [May 22, 2019, 9:16am UTC](https://discuss.elastic.co/t/logstash-filter-to-combine-patterns-together/182184 "2019-05-22T09:16:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![unicxs\_support](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/unicxs_support/32/46602_2.png) [@unicxs\_support](https://discuss.elastic.co/u/unicxs_support)\
**Post date:** [May 22, 2019, 9:16am UTC](https://discuss.elastic.co/t/logstash-filter-to-combine-patterns-together/182184/1 "2019-05-22T09:16:42Z")

</div>

Hello Experts,

I've Just started evaluating the ELK and working great , we are trying to get this product to be used. I'm using 6.5 Version.

Below are log patterns..

```
oradb001,10/03/22,00:29,00-mins
oradb002,11/03/21,18:09,-mins

```

So, When I'm trying the below grok on the above log pattern, its gives below shown results..

```
%{HOSTNAME:hostname},(?<datetime>\d{2}/\d{2}/\d{2},\d{2}:\d{2}),(%{NUMBER:duration}-mins)?(%{NUMBER:duration_hrs}-hrs)?

```

Result for the First line of text as follows..

```
{
  "duration": "00",
  "hostname": "oradb001",
  "datetime": "11/03/21,18:09"
}

```

While for the Second line it produces below..

```
{
  "hostname": "oradb001",
  "datetime": "11/03/21,18:09"
}

```

Second approach with just changing grok..

1. 

```
%{HOSTNAME:Hostname},%{DATE:Date},%{HOUR:Time_h}:%{MINUTE:Time_m},%{NUMBER:duration}-%{WORD:tt}

```

**Result:**

```
{
  "duration": "00",
  "tt": "mins",
  "Time_h": "18",
  "Hostname": "oradb001",
  "Time_m": "09",
  "Date": "11/03/21"
}

```

1. 

```
%{HOSTNAME:Hostname},%{DATE:Date},%{HOUR:Time_h}:%{MINUTE:Time_m},-%{WORD:Duration}

```

**Result:**

```
{
  "Time_h": "18",
  "Hostname": "oradb001",
  "Time_m": "09",
  "Duration": "mins",
  "Date": "11/03/21"
}

```

**Desired:**

```
{
  "hostname": "oradb001",
  "datetime": "11/03/21,18:09"
  "duration":"-mins"
}

```

OR

```
   {
      "hostname": "oradb001",
      "datetime": "11/03/21,18:09"
      "duration":"00-mins"
    }
```

---

<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:** [May 22, 2019, 12:13pm UTC](https://discuss.elastic.co/t/logstash-filter-to-combine-patterns-together/182184/2 "2019-05-22T12:13:22Z")

</div>

You could do that with a dissect filter. The first field is delimited by a comma, the third by a hyphen.

---

<div class="post-metadata">

**Author:** ![unicxs\_support](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/unicxs_support/32/46602_2.png) [@unicxs\_support](https://discuss.elastic.co/u/unicxs_support)\
**Post date:** [May 22, 2019, 1:47pm UTC](https://discuss.elastic.co/t/logstash-filter-to-combine-patterns-together/182184/3 "2019-05-22T13:47:46Z")

</div>

Thanks Badger, i will check that.

---

<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:** [June 19, 2019, 1:47pm UTC](https://discuss.elastic.co/t/logstash-filter-to-combine-patterns-together/182184/4 "2019-06-19T13:47:48Z")

</div>

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