# How to filter/remove fields that have certain naming pattern

**URL:** <https://discuss.elastic.co/t/how-to-filter-remove-fields-that-have-certain-naming-pattern/80562>\
**Category:** Logstash\
**Created:** [March 29, 2017, 11:53pm UTC](https://discuss.elastic.co/t/how-to-filter-remove-fields-that-have-certain-naming-pattern/80562 "2017-03-29T23:53:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dixitnikhil2004](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@dixitnikhil2004](https://discuss.elastic.co/u/dixitnikhil2004)\
**Post date:** [March 29, 2017, 11:53pm UTC](https://discuss.elastic.co/t/how-to-filter-remove-fields-that-have-certain-naming-pattern/80562/1 "2017-03-29T23:53:34Z")

</div>

with JSON input, i have field like  
Name:Value  
build.artifacts.hyper-mingw64-x86\_64-debug-master.0.0.1677.rd3e0b27a.tgz.archive: "SOME VALUE1"  
build.artifacts.hyper-mingw64-x86\_64-debug-master.0.0.1677.rd3e0b27a.zip.archive: "SOME VALUE2"  
build.artifacts.hyper-symbols-mingw64-x86\_64-debug-master.0.0.1677.rd3e0b27a.tgz.archive : "SOME VALUE3"  
etc

I would like to suppress/ mutate-\>remove fields to such fields. in logstash filter,

1. how can we search for pattern like field names starting with "build.artifacts\*"?
2. how can we find the length of field name if needed?

note: here i want to search the key and not its value.

please advise

---

<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:** [March 30, 2017, 5:21am UTC](https://discuss.elastic.co/t/how-to-filter-remove-fields-that-have-certain-naming-pattern/80562/2 "2017-03-30T05:21:57Z")

</div>

Does the prune filter help?

> how can we find the length of field name if needed?

You probably need to use a ruby filter. What do you want to do with the length?

---

<div class="post-metadata">

**Author:** ![dixitnikhil2004](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@dixitnikhil2004](https://discuss.elastic.co/u/dixitnikhil2004)\
**Post date:** [April 4, 2017, 6:32pm UTC](https://discuss.elastic.co/t/how-to-filter-remove-fields-that-have-certain-naming-pattern/80562/3 "2017-04-04T18:32:14Z")

</div>

thank you Magnus.

Objective: to ignore any json fields that are under this structure "build.artifacts.\*"  
Example:  
build.artifacts.hyper-mingw64-x86\_64-debug-master.0.0.1677.rd3e0b27a.tgz.archive: "SOME VALUE1"  
build.artifacts.hyper-mingw64-x86\_64-debug-master.0.0.1677.rd3e0b27a.zip.archive: "SOME VALUE2"

i tried the following construct that didint work  
prune{  
blacklist\_names =\> ["%{[build][artifacts]}"]

}

can you please advise?

---

<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:** [April 6, 2017, 5:15am UTC](https://discuss.elastic.co/t/how-to-filter-remove-fields-that-have-certain-naming-pattern/80562/4 "2017-04-06T05:15:09Z")

</div>

Yeah, the prune filter doesn't work with nested fields. If you want to delete the whole `[build][artifacts]` hierarchy a simple mutate filter that deletes `[build][artifacts]` should do.

---

<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:** [May 4, 2017, 5:15am UTC](https://discuss.elastic.co/t/how-to-filter-remove-fields-that-have-certain-naming-pattern/80562/5 "2017-05-04T05:15:14Z")

</div>

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