# Logstash - Add fields from the log fields property - Grok

**URL:** https://discuss.elastic.co/t/logstash-add-fields-from-the-log-fields-property-grok/70100
**Category:** Logstash
**Created:** [December 28, 2016, 12:59am UTC](https://discuss.elastic.co/t/logstash-add-fields-from-the-log-fields-property-grok/70100 "2016-12-28T00:59:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![AleGallagher](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@AleGallagher](https://discuss.elastic.co/u/AleGallagher)
#### Post date: [December 28, 2016, 12:59am UTC](https://discuss.elastic.co/t/logstash-add-fields-from-the-log-fields-property-grok/70100/1 "2016-12-28T00:59:34Z")

</div>

I'm learning logstash and I'm using Kibana to see the logs. I would like to know if is there anyway to add fields using data from message property.

For example, the log is like this:

port:46,722 host:172.18.0.5 **message** :{"@timestamp":"2016-12-28T00:34:53.198+00:00","@version":1,"message":"Entrada de datos incompletos","logger\_name":"com.empresa.miAlquiler.controllers.UserController","thread\_name":"http-nio-7777-exec-2","level":"INFO","level\_value":20000,"HOSTNAME":"8fe48aff9ca8", **"spring.application.name"** :"visit-service","X-Span-Export":"false","X-B3-SpanId":"1cccc5c7252100c4","X-B3-TraceId":"1cccc5c7252100c4"} tags:\_grokparsefailure

message, is a field. I want to get **spring.application.name** from **message** and convert it as a field, to filter the logs with it with Kibana.

How can I do that?

My Logstash conf file, looks like:

> filter {  
> grok {  
> match =\> {  
> "message" =\>  
> "^%{TIMESTAMP\_ISO8601:timestamp}\s+%{LOGLEVEL:level}\s+%{NUMBER:pid}\s+---\s+[\s\*%{USERNAME:thread}\s\*]\s+%{JAVAFILE:logger\_name}\s\*:\s\*%{DATA:themessage}(?:\n+(?(?:.|\r|\n)+))?$"  
> }  
> }  
> date {  
> match =\> ["timestamp" , "yyyy-MM-dd HH:mm:ss.SSS"]  
> }  
> mutate {  
> remove\_field =\> ["@version"]

> ```
> add_field => {"service_name" => "%{spring.application.name}"}
> 
> ```

> }  
> }

Thanks! 🙂

---

<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: [December 31, 2016, 1:17pm UTC](https://discuss.elastic.co/t/logstash-add-fields-from-the-log-fields-property-grok/70100/2 "2016-12-31T13:17:37Z")

</div>

Do not parse JSON strings with grok filters. Either change your input's codec to json or json\_lines or use a json filter to parse the `message` field.

---

<div class="post-metadata">

### Author: ![AleGallagher](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@AleGallagher](https://discuss.elastic.co/u/AleGallagher)
#### Post date: [January 3, 2017, 1:03pm UTC](https://discuss.elastic.co/t/logstash-add-fields-from-the-log-fields-property-grok/70100/3 "2017-01-03T13:03:32Z")

</div>

It works! Thank you very much! 🙂

---

<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: [January 31, 2017, 1:03pm UTC](https://discuss.elastic.co/t/logstash-add-fields-from-the-log-fields-property-grok/70100/4 "2017-01-31T13:03:36Z")

</div>

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