# Creating new field with logstash

**URL:** <https://discuss.elastic.co/t/creating-new-field-with-logstash/49194>\
**Category:** Logstash\
**Created:** [May 4, 2016, 2:57pm UTC](https://discuss.elastic.co/t/creating-new-field-with-logstash/49194 "2016-05-04T14:57:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kennedy\_Kan1](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Kennedy\_Kan1](https://discuss.elastic.co/u/Kennedy_Kan1)\
**Post date:** [May 4, 2016, 2:57pm UTC](https://discuss.elastic.co/t/creating-new-field-with-logstash/49194/1 "2016-05-04T14:57:31Z")

</div>

I have a file named "Job Code.txt"

> job\_id=0001,description=Ship data from server to elknode1,result=OK  
> job\_id=0002,description=Ship data from server to elknode2,result=Error: Msg...  
> job\_id=0003,description=Ship data from server to elknode3,result=OK  
> job\_id=0004,description=Ship data from server to elknode4,result=OK

Here is the filter part of my .conf file but it doesn't work. How can I created new field, i.e. jobID, description, result as to be seen in kibana

> filter{  
> grok{ match =\> {"message" =\> ["JobID: %{NOTSPACE:job\_id}","description: %{NOTSPACE:description}","result: %{NOTSPACE:message}"]}  
> add\_field =\> {  
> "JobID" =\> "%{job\_id}"  
> "Description" =\> "%{description}"  
> "Message" =\> "%{message}"  
> }  
> }  
> if [job\_id] == "0001" {  
> aggregate {  
> task\_id =\> "%{job\_id}"  
> code =\> "map['time\_elasped']=0"  
> map\_action =\> "create"  
> }  
> }  
> if [job\_id] == "0003" {  
> aggregate {  
> task\_id =\> "%{job\_id}"  
> code =\> "map['time\_elasped']=0"  
> map\_action =\> "update"  
> }  
> }  
> if [job\_id] == "0002" {  
> aggregate {  
> task\_id =\> "%{job\_id}"  
> code =\> "map['time\_elasped']=0"  
> map\_action =\> "update"  
> }  
> }

---

<div class="post-metadata">

**Author:** ![fbaligand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fbaligand/32/5657_2.png) [@fbaligand](https://discuss.elastic.co/u/fbaligand)\
**Post date:** [May 5, 2016, 8:26am UTC](https://discuss.elastic.co/t/creating-new-field-with-logstash/49194/2 "2016-05-05T08:26:33Z")

</div>

I invite you to fix your grok configuration :

```
grok{
  match => {"message" => ["job_id=%{NOTSPACE:job_id},description=%{DATA:description},result= 
%{GREEDYDATA:result}"]
}

```

If in Kibana, you aim to have a field named JobID, you can directly name your field JobID in grok expression :

```
grok{
  match => {"message" => ["job_id=%{NOTSPACE:JobID},description=%{DATA:description},result= 
%{GREEDYDATA:result}"]
}
```

---

<div class="post-metadata">

**Author:** ![fbaligand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fbaligand/32/5657_2.png) [@fbaligand](https://discuss.elastic.co/u/fbaligand)\
**Post date:** [May 5, 2016, 5:03pm UTC](https://discuss.elastic.co/t/creating-new-field-with-logstash/49194/3 "2016-05-05T17:03:18Z")

</div>

Given your log line format, I advice you to use "kv" filter rather than "grok" :

```
kv {
  field_split => ","
}
```

---

<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:59am UTC](https://discuss.elastic.co/t/creating-new-field-with-logstash/49194/4 "2017-07-06T04:59:15Z")

</div>


