# Which algorithms are used in grok filter to find exact match?

**URL:** https://discuss.elastic.co/t/which-algorithms-are-used-in-grok-filter-to-find-exact-match/130090
**Category:** Logstash
**Created:** [May 1, 2018, 6:27am UTC](https://discuss.elastic.co/t/which-algorithms-are-used-in-grok-filter-to-find-exact-match/130090 "2018-05-01T06:27:16Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![RameshNagargoje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rameshnagargoje/32/30212_2.png) [@RameshNagargoje](https://discuss.elastic.co/u/RameshNagargoje)
#### Post date: [May 1, 2018, 6:27am UTC](https://discuss.elastic.co/t/which-algorithms-are-used-in-grok-filter-to-find-exact-match/130090/1 "2018-05-01T06:27:17Z")

</div>

Hi all, I am using grok filter to find an exact match in logs. My logs size would be 10 mb. And streaming of logs is continuing going on. I am not getting that every time match is searched in 10 mb of log size Will it be good or not.

Algorithms used are efficient or not.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [May 1, 2018, 6:33am UTC](https://discuss.elastic.co/t/which-algorithms-are-used-in-grok-filter-to-find-exact-match/130090/2 "2018-05-01T06:33:26Z")

</div>

It would help if you share your config and provide a more detailed description of what you are looking to do. Logstash by default processes the data in the log file line by line, so will not run grok against the full file.

---

<div class="post-metadata">

### Author: ![RameshNagargoje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rameshnagargoje/32/30212_2.png) [@RameshNagargoje](https://discuss.elastic.co/u/RameshNagargoje)
#### Post date: [May 1, 2018, 6:36am UTC](https://discuss.elastic.co/t/which-algorithms-are-used-in-grok-filter-to-find-exact-match/130090/3 "2018-05-01T06:36:44Z")

</div>

@Christian_Dahlqvist here is the snapshot of logs

rxctl: rxcnt\_timeout=5, rxlen=0  
15119.753889] [] (kthread+0xe0/0xe4) from [] (ret\_from\_fork+0x14/0x20)  
15119.753889] dhd\_bus\_rxctl: rxcnt\_timeout=5, rxlen=0  
15119.753889] dhd\_bus\_rxctl: rxcnt\_timeout=5, rxlen=0  
15119.753889] dhd\_bus\_rxctl: rxcnt\_timeout=5, rxlen=0  
15119.753889] dhd\_bus\_rxctl: rxcnt\_timeout=5, rxlen=0  
[15119.753902] Dhd\_check\_hang: Event HANG send up due to re=5 te=0 e=-110 s=2  
[15119.753917] Dhd\_check\_hang: Event HANG send up due to re=5 te=0 e=-110 s=2  
[15119.753937] Dhd\_prot\_ioctl : bus is down. we have nothing to do  
[15119.791431] [] (schedule\_timeout+0x158/0x25c) from [] (0xea1e0000)  
[15119.799331] kworker/3:2 R running 0 29597 2 0x00000000  
[15119.805699] [] (\_\_schedule+0x3d0/0x8a4) from [] (worker\_thread+0x1fc/0x3dc)  
[15119.814384] [] (worker\_thread+0x1fc/0x3dc) from [] (kthread+0xe0/0xe4)  
[15119.822637] [] (kthread+0xe0/0xe4) from [] (ret\_from\_fork+0x14/0x20)  
[15119.830710] kworker/u8:1 S c0ab2fd4 0 29738 2 0x00000000  
[15119.837078] [] (\_\_schedule+0x3d0/0x8a4) from [] (worker\_thread+0x1fc/0x3dc)  
[15119.845763] [] (worker\_thread+0x1fc/0x3dc) from [] (kthread+0xe0/0xe4)  
[15119.854015] [] (kthread+0xe0/0xe4) from [] (ret\_from\_fork+0x14/0x20)  
[15119.862088] kworker/u8:4 S c0ab2fd4 0 29739 2 0x00000000  
[15119.868455] [] (\_\_schedule+0x3d0/0x8a4) from [] (worker\_thread+0x1fc/0x3dc)  
[15119.877140] [] (worker\_thread+0x1fc/0x3dc) from [] (kthread+0xe0/0xe4)  
[15119.885391] [] (kthread+0xe0/0xe4) from [] (ret\_from\_fork+0x14/0x20)  
[15119.893468] Sched Debug Version: v0.10, 3.10.96+ #1  
[15119.898337] ktime

And filter used is

grok  
{  
match =\> { logs =\> "dhd\_check\_hang: Event HANG send up due to"}  
}

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [May 1, 2018, 6:42am UTC](https://discuss.elastic.co/t/which-algorithms-are-used-in-grok-filter-to-find-exact-match/130090/4 "2018-05-01T06:42:56Z")

</div>

What is the expected output/result?

---

<div class="post-metadata">

### Author: ![RameshNagargoje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rameshnagargoje/32/30212_2.png) [@RameshNagargoje](https://discuss.elastic.co/u/RameshNagargoje)
#### Post date: [May 1, 2018, 6:43am UTC](https://discuss.elastic.co/t/which-algorithms-are-used-in-grok-filter-to-find-exact-match/130090/5 "2018-05-01T06:43:40Z")

</div>

expected output result is

[15119.753902] Dhd\_check\_hang: Event HANG send up due to re=5 te=0 e=-110 s=2  
[15119.753917] Dhd\_check\_hang: Event HANG send up due to re=5 te=0 e=-110 s=2

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [May 1, 2018, 6:45am UTC](https://discuss.elastic.co/t/which-algorithms-are-used-in-grok-filter-to-find-exact-match/130090/6 "2018-05-01T06:45:51Z")

</div>

Are you looking to filter out all lines that does not match that pattern? What do you want the resulting document being sent to Elasticsearch to look like?

---

<div class="post-metadata">

### Author: ![RameshNagargoje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rameshnagargoje/32/30212_2.png) [@RameshNagargoje](https://discuss.elastic.co/u/RameshNagargoje)
#### Post date: [May 1, 2018, 6:47am UTC](https://discuss.elastic.co/t/which-algorithms-are-used-in-grok-filter-to-find-exact-match/130090/7 "2018-05-01T06:47:58Z")

</div>

I am using grok filter to find regex match in logs and extract only those line and dumps these lines in ES

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [May 1, 2018, 6:58am UTC](https://discuss.elastic.co/t/which-algorithms-are-used-in-grok-filter-to-find-exact-match/130090/8 "2018-05-01T06:58:09Z")

</div>

Would something like this work?

```auto
if [message] !~ /Dhd_check_hang: Event HANG send up due to/ {
  drop {}
}

```

---

<div class="post-metadata">

### Author: ![RameshNagargoje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rameshnagargoje/32/30212_2.png) [@RameshNagargoje](https://discuss.elastic.co/u/RameshNagargoje)
#### Post date: [May 1, 2018, 7:11am UTC](https://discuss.elastic.co/t/which-algorithms-are-used-in-grok-filter-to-find-exact-match/130090/9 "2018-05-01T07:11:37Z")

</div>

If it will check line by line then it will take more time to finad match and dump

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [May 1, 2018, 7:27am UTC](https://discuss.elastic.co/t/which-algorithms-are-used-in-grok-filter-to-find-exact-match/130090/10 "2018-05-01T07:27:29Z")

</div>

> If it will check line by line then it will take more time to finad match and dump

Maybe. Have you measured?

The background of your questions is unclear. What are you getting at?

---

<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: [May 29, 2018, 7:27am UTC](https://discuss.elastic.co/t/which-algorithms-are-used-in-grok-filter-to-find-exact-match/130090/11 "2018-05-29T07:27:36Z")

</div>

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