# Grab value from message field and add it to a new field

**URL:** <https://discuss.elastic.co/t/grab-value-from-message-field-and-add-it-to-a-new-field/49358>\
**Category:** Logstash\
**Created:** [May 5, 2016, 11:53pm UTC](https://discuss.elastic.co/t/grab-value-from-message-field-and-add-it-to-a-new-field/49358 "2016-05-05T23:53:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![niraj\_kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_kumar/32/4130_2.png) [@niraj\_kumar](https://discuss.elastic.co/u/niraj_kumar)\
**Post date:** [May 5, 2016, 11:53pm UTC](https://discuss.elastic.co/t/grab-value-from-message-field-and-add-it-to-a-new-field/49358/1 "2016-05-05T23:53:09Z")

</div>

Hi,

How do i grab a particular value from my initial message field and use to configure it in a new field.

My message field looks like this:

2016-05-05 23:47:30,939 INFO [qtp796460995-1114] [puppet-server] Puppet 'store report' command for niraj-dev-03-shard2-mongodb03 submitted to PuppetDB with UUID 6c209aa7-540f-431f-88f5-75c84dca2fa7

I want the hostname niraj-dev-03-shard2-mongodb03 from my message field and use that to create a new field named host. How do i achieve this.

--  
Niraj

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 6, 2016, 1:42am UTC](https://discuss.elastic.co/t/grab-value-from-message-field-and-add-it-to-a-new-field/49358/2 "2016-05-06T01:42:33Z")

</div>

You can use grok to match the entire pattern, then you can use that field elsewhere - [https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html](https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html)

---

<div class="post-metadata">

**Author:** ![niraj\_kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_kumar/32/4130_2.png) [@niraj\_kumar](https://discuss.elastic.co/u/niraj_kumar)\
**Post date:** [May 6, 2016, 3:11am UTC](https://discuss.elastic.co/t/grab-value-from-message-field-and-add-it-to-a-new-field/49358/3 "2016-05-06T03:11:19Z")

</div>

It would be really helpful if you can demonstrate and example. I had a look at this website but seems to be bit confusing.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 6, 2016, 4:26am UTC](https://discuss.elastic.co/t/grab-value-from-message-field-and-add-it-to-a-new-field/49358/4 "2016-05-06T04:26:06Z")

</div>

Maybe this will be better [https://www.elastic.co/guide/en/logstash/current/advanced-pipeline.html#configuring-grok-filter](https://www.elastic.co/guide/en/logstash/current/advanced-pipeline.html#configuring-grok-filter)

---

<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 6, 2016, 9:37pm UTC](https://discuss.elastic.co/t/grab-value-from-message-field-and-add-it-to-a-new-field/49358/5 "2016-05-06T21:37:59Z")

</div>

```
grok {
  match => ["message", "command for %{NOTSPACE:host}"]
}
```

---

<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:58am UTC](https://discuss.elastic.co/t/grab-value-from-message-field-and-add-it-to-a-new-field/49358/6 "2017-07-06T04:58:57Z")

</div>


