# Adding new fields from grok filter in logstash

**URL:** <https://discuss.elastic.co/t/adding-new-fields-from-grok-filter-in-logstash/153570>\
**Category:** Logstash\
**Created:** [October 23, 2018, 9:59am UTC](https://discuss.elastic.co/t/adding-new-fields-from-grok-filter-in-logstash/153570 "2018-10-23T09:59:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![userASR](https://avatars.discourse-cdn.com/v4/letter/u/898d66/32.png) [@userASR](https://discuss.elastic.co/u/userASR)\
**Post date:** [October 23, 2018, 9:59am UTC](https://discuss.elastic.co/t/adding-new-fields-from-grok-filter-in-logstash/153570/1 "2018-10-23T09:59:34Z")

</div>

I have a grok filter in my logstash conf. Where I match a message and I want to add a new field "newfield" and populate value from one specific field "data1" from the message. Here is how my configuration looks like:

```auto
input {
  file {
    path => "/var/log/myapp/myapp.log"
    sincedb_path => "/var/log/logstash/.sincedb2/myapp.log"
    start_position => beginning
    type => "myapp"
  }
}
filter {
   grok {
        match => {
          "message" => "%{TIMESTAMP_ISO8601:timestamp}\s+%{LOGLEVEL:loglevel}\s+%{JAVACLASS:class}:\s+%{WORD:word1}\s+%{WORD:word2}:\s+%{WORD:word3}=%{DATA:data1}+%{GREEDYDATA:content}"
       }
    }
    mutate {
        add_field => ["newfield", "%{data1}"]
    }
   if ("grokparsefailure" in [tags]) { drop {} }
}
output {
  if [type] == "myapp"{
    elasticsearch {
      hosts => [{% for node in elastic_data_hosts %}"{{node}}:{{elastic_port}}"{% if not loop.last %},{% endif %}{% endfor %}]
      index => "logstash-myapp-log"
     }
  }
}

```

I can see the new field added on Kibana but the value is not getting assigned. Am I doing it wrong or missed anything?

---

<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:** [November 20, 2018, 10:06am UTC](https://discuss.elastic.co/t/adding-new-fields-from-grok-filter-in-logstash/153570/2 "2018-11-20T10:06:14Z")

</div>

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