# Extracting a key value pair in which the key contains certain string

**URL:** https://discuss.elastic.co/t/extracting-a-key-value-pair-in-which-the-key-contains-certain-string/108384
**Category:** Logstash
**Created:** [November 20, 2017, 12:41pm UTC](https://discuss.elastic.co/t/extracting-a-key-value-pair-in-which-the-key-contains-certain-string/108384 "2017-11-20T12:41:49Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![abhilash3011](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@abhilash3011](https://discuss.elastic.co/u/abhilash3011)
#### Post date: [November 20, 2017, 12:41pm UTC](https://discuss.elastic.co/t/extracting-a-key-value-pair-in-which-the-key-contains-certain-string/108384/1 "2017-11-20T12:41:49Z")

</div>

Hi all, I am parsing my data as key value pair using kv filter.  
I want to extract only the key which contain a certain string. For example if my string is "name". then i want to extract keys which are "myname", yourname, company\_name etc. Is there any way to do it without writing ruby code?

---

<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: [November 22, 2017, 9:14am UTC](https://discuss.elastic.co/t/extracting-a-key-value-pair-in-which-the-key-contains-certain-string/108384/2 "2017-11-22T09:14:22Z")

</div>

The kv filter doesn't support this out of the box, but you can use a prune filter to remove fields except those matching a regexp.

---

<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: [December 20, 2017, 9:14am UTC](https://discuss.elastic.co/t/extracting-a-key-value-pair-in-which-the-key-contains-certain-string/108384/3 "2017-12-20T09:14:22Z")

</div>

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