# Grok filter is not working (custom pattern)

**URL:** <https://discuss.elastic.co/t/grok-filter-is-not-working-custom-pattern/82017>\
**Category:** Logstash\
**Created:** [April 11, 2017, 4:24pm UTC](https://discuss.elastic.co/t/grok-filter-is-not-working-custom-pattern/82017 "2017-04-11T16:24:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ibrahimsharaf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ibrahimsharaf/32/17304_2.png) [@ibrahimsharaf](https://discuss.elastic.co/u/ibrahimsharaf)\
**Post date:** [April 11, 2017, 4:24pm UTC](https://discuss.elastic.co/t/grok-filter-is-not-working-custom-pattern/82017/1 "2017-04-11T16:24:39Z")

</div>

I've a log file ([http://codepad.org/vAMFhhR2](http://codepad.org/vAMFhhR2)), and I want to extract a specific number out of it (line 18)  
I wrote a custom pattern grok filter, tested it on [http://grokdebug.herokuapp.com/](http://grokdebug.herokuapp.com/), it works fine and extracts my desired value.

here's how logstash.conf looks like ([http://codepad.org/FxY8ZXUa](http://codepad.org/FxY8ZXUa))  
but it doesn't match any record from the same log on Kibana

can you help?

---

<div class="post-metadata">

**Author:** ![jkuang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jkuang/32/72637_2.png) [@jkuang](https://discuss.elastic.co/u/jkuang)\
**Post date:** [April 11, 2017, 6:25pm UTC](https://discuss.elastic.co/t/grok-filter-is-not-working-custom-pattern/82017/2 "2017-04-11T18:25:53Z")

</div>

What is the query you are using when running in Kibana?

---

<div class="post-metadata">

**Author:** ![ibrahimsharaf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ibrahimsharaf/32/17304_2.png) [@ibrahimsharaf](https://discuss.elastic.co/u/ibrahimsharaf)\
**Post date:** [April 12, 2017, 10:29am UTC](https://discuss.elastic.co/t/grok-filter-is-not-working-custom-pattern/82017/3 "2017-04-12T10:29:33Z")

</div>

I don't run any queries on kibana @jkuang.

---

<div class="post-metadata">

**Author:** ![raamee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raamee/32/5110_2.png) [@raamee](https://discuss.elastic.co/u/raamee)\
**Post date:** [April 12, 2017, 11:06am UTC](https://discuss.elastic.co/t/grok-filter-is-not-working-custom-pattern/82017/4 "2017-04-12T11:06:36Z")

</div>

Have you checked by making the logstash to stdout insted of elasticsearch? Can you paste the output here?

```
input {
	tcp {
		port => 5000
	}
}

## Add your filters / logstash plugins configuration here
filter {
	grok{
		 match => ["message", "(?<scraped>(?<='item_scraped_count': ).*(?=,))"]
	}
}

output {
	stdout {
		codec => rubydebug
	}
}
```

---

<div class="post-metadata">

**Author:** ![ibrahimsharaf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ibrahimsharaf/32/17304_2.png) [@ibrahimsharaf](https://discuss.elastic.co/u/ibrahimsharaf)\
**Post date:** [April 12, 2017, 11:24am UTC](https://discuss.elastic.co/t/grok-filter-is-not-working-custom-pattern/82017/5 "2017-04-12T11:24:40Z")

</div>

```
{
logstash_1 | "@timestamp" => 2017-04-12T11:22:38.841Z,
logstash_1 | "port" => 39100,
logstash_1 | "@version" => "1",
logstash_1 | "host" => "172.18.0.1",
logstash_1 | "message" => "2017-01-01 07:57:22 [statscollectors.py] INFO: Dumping Scrapy stats:",
logstash_1 | "tags" => [
logstash_1 | [0] "_grokparsefailure"
logstash_1 | ]
logstash_1 | }

```

here's a part of the output, its the same for every line in the log, I guess there's a problem in my regex.

---

<div class="post-metadata">

**Author:** ![jkuang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jkuang/32/72637_2.png) [@jkuang](https://discuss.elastic.co/u/jkuang)\
**Post date:** [April 12, 2017, 6:21pm UTC](https://discuss.elastic.co/t/grok-filter-is-not-working-custom-pattern/82017/6 "2017-04-12T18:21:29Z")

</div>

In Logstash the grok must match all fields and then you can extract the particular you want. The grokdebug you provided just ignores other fields besides the one you specified.

---

<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 10, 2017, 6:23pm UTC](https://discuss.elastic.co/t/grok-filter-is-not-working-custom-pattern/82017/7 "2017-05-10T18:23:26Z")

</div>

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