# Grok match and move all to subfield

**URL:** <https://discuss.elastic.co/t/grok-match-and-move-all-to-subfield/198633>\
**Category:** Logstash\
**Created:** [September 9, 2019, 8:45am UTC](https://discuss.elastic.co/t/grok-match-and-move-all-to-subfield/198633 "2019-09-09T08:45:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vincentvm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vincentvm/32/40284_2.png) [@vincentvm](https://discuss.elastic.co/u/vincentvm)\
**Post date:** [September 9, 2019, 8:45am UTC](https://discuss.elastic.co/t/grok-match-and-move-all-to-subfield/198633/1 "2019-09-09T08:45:14Z")

</div>

Is it possible to move all fields matched by grok to a subfield?

```auto
if [program] == "nginx-error" {
 grok {
   match => ["message" , "%{NGINX_ERROR}"]
   add_tag => ["nginx-error"]
 }
}

```

I would like to move this for example to the `nginx-error` field in a document and not have all the matches in the document root.

I know I can edit the pattern file but this is a lot of work and was wondering if this could be done easier.

---

<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:** [October 7, 2019, 8:45am UTC](https://discuss.elastic.co/t/grok-match-and-move-all-to-subfield/198633/2 "2019-10-07T08:45:17Z")

</div>

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