# Logstash grok matching entire filebeat message instead of message inside

**URL:** https://discuss.elastic.co/t/logstash-grok-matching-entire-filebeat-message-instead-of-message-inside/64976
**Category:** Logstash
**Created:** [November 4, 2016, 5:41am UTC](https://discuss.elastic.co/t/logstash-grok-matching-entire-filebeat-message-instead-of-message-inside/64976 "2016-11-04T05:41:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![elasticheart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticheart/32/65189_2.png) [@elasticheart](https://discuss.elastic.co/u/elasticheart)
#### Post date: [November 4, 2016, 5:41am UTC](https://discuss.elastic.co/t/logstash-grok-matching-entire-filebeat-message-instead-of-message-inside/64976/1 "2016-11-04T05:41:27Z")

</div>

I have setup Filebeat -\> Kafka -\> Logstash -\> Elasticseatch system.

I have filebeat output like;

```
{"@timestamp":"2016-11-04T05:16:16.108Z","beat":{"hostname":"localhost","name":"localhost","version":"5.0.0"},"fields":{"logtype":"logfile"},"input_type":"log","message":"\u003cOct 31, 2016 6:37:40:678 AM\u003e \u003cdataa\u003e \u003cdatab\u003e \u003cdatac\u003e \u003datad\u003e \u003cdatae\u003e \u003cdataf\u003e \u003cgatag\u003e\n \u003cdatah\u003e","offset":273,"source":"/logfiles/logfile.log","type":"logfile"}

```

I have setup logstash grok to match this message like;

```
grok {
	match => { "message" => "%{GREEDYDATA:messageDataA}" }
}

```

But it is pushing entire beat data like @timestamp, hostname, etc (the whole filebeat output line I have mentioned above) to `messageDataA` field. But I want to push only the `message` part inside filebeat message to be pushed. How can I do this? I am using 5.0 GA of Filebeat and Logstash.

---

<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: [November 4, 2016, 5:53am UTC](https://discuss.elastic.co/t/logstash-grok-matching-entire-filebeat-message-instead-of-message-inside/64976/2 "2016-11-04T05:53:53Z")

</div>

It sounds like you're missing a `codec => json` setting in your kafka input. Please show your configuration and the output of a `stdout { codec => rubydebug }` output.

Using grok to copy data from one field to another is inefficient and unnecessary. Use a mutate filter to rename the field instead (or copy the field value with add\_field if you really want to keep both fields).

---

<div class="post-metadata">

### Author: ![elasticheart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticheart/32/65189_2.png) [@elasticheart](https://discuss.elastic.co/u/elasticheart)
#### Post date: [November 4, 2016, 5:59am UTC](https://discuss.elastic.co/t/logstash-grok-matching-entire-filebeat-message-instead-of-message-inside/64976/3 "2016-11-04T05:59:21Z")

</div>

`codec => json` solved the issue. Thanks a lot 🙂

---

<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: [July 6, 2017, 4:31am UTC](https://discuss.elastic.co/t/logstash-grok-matching-entire-filebeat-message-instead-of-message-inside/64976/4 "2017-07-06T04:31:11Z")

</div>


