# How to add new fields from specific set of strings in the message?

**URL:** <https://discuss.elastic.co/t/how-to-add-new-fields-from-specific-set-of-strings-in-the-message/52799>\
**Category:** Logstash\
**Created:** [June 15, 2016, 3:02am UTC](https://discuss.elastic.co/t/how-to-add-new-fields-from-specific-set-of-strings-in-the-message/52799 "2016-06-15T03:02:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![khizaralvi](https://avatars.discourse-cdn.com/v4/letter/k/57b2e6/32.png) [@khizaralvi](https://discuss.elastic.co/u/khizaralvi)\
**Post date:** [June 15, 2016, 3:02am UTC](https://discuss.elastic.co/t/how-to-add-new-fields-from-specific-set-of-strings-in-the-message/52799/1 "2016-06-15T03:02:43Z")

</div>

Hi everyone,

I have a log file which records the query stats of a MongoDB server.

2016-06-06T00:31:14.848-0700 I COMMAND [conn55216] query ums.broadcasts query: { $readPreference: { mode: "secondary" }, $query: { status.state: "SEND\_IN\_PROGRESS", status.chanStats.EMAIL.state: { $nin: ["IN\_PROGRESS", "PENDING"] }, status.chanStats.SMS.state: { $nin: ["IN\_PROGRESS", "PENDING"] }, status.chanStats.APNS\_PUSH.state: { $nin: ["IN\_PROGRESS", "PENDING"] }, status.chanStats.GCM.state: { $nin: ["IN\_PROGRESS", "PENDING"] }, status.chanStats.TWT.state: { $nin: ["IN\_PROGRESS", "PENDING"] }, status.chanStats.ADM.state: { $nin: ["IN\_PROGRESS", "PENDING"] }, status.chanStats.WINP7.state: { $nin: ["IN\_PROGRESS", "PENDING"] }, status.chanStats.WINP8.state: { $nin: ["IN\_PROGRESS", "PENDING"] }, status.chanStats.WIN8.state: { $nin: ["IN\_PROGRESS", "PENDING"] }, status.chanStats.INBOX.state: { $nin: ["IN\_PROGRESS", "PENDING"] } } } planSummary: IXSCAN { status.state: 1.0 } ntoreturn:0 ntoskip:0 nscanned:22055 nscannedObjects:22055 keyUpdates:0 writeConflicts:0 numYields:172 nreturned:9 reslen:11810 locks:{ Global: { acquireCount: { r: 346 } }, MMAPV1Journal: { acquireCount: { r: 173 } }, Database: { acquireCount: { r: 173 } }, Collection: { acquireCount: { R: 173 } } } 121ms

I want to capture specific data like numYields:172, nscannedObjects:22055, Database: { acquireCount: { r: 173 } }, Collection: { acquireCount: { R: 173 } } and turn them into separate fields? Any idea how would I do that? Any help would be deeply appreciated! 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:** [June 19, 2016, 10:23am UTC](https://discuss.elastic.co/t/how-to-add-new-fields-from-specific-set-of-strings-in-the-message/52799/2 "2016-06-19T10:23:07Z")

</div>

The grok filter is frequently used for this task, but sometimes a kv filter is easier. In this case I'd probably use grok.

---

<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:52am UTC](https://discuss.elastic.co/t/how-to-add-new-fields-from-specific-set-of-strings-in-the-message/52799/3 "2017-07-06T04:52:03Z")

</div>


