# Writing to Metadata with a custom pattern in grok

**URL:** <https://discuss.elastic.co/t/writing-to-metadata-with-a-custom-pattern-in-grok/116688>\
**Category:** Logstash\
**Created:** [January 23, 2018, 2:23pm UTC](https://discuss.elastic.co/t/writing-to-metadata-with-a-custom-pattern-in-grok/116688 "2018-01-23T14:23:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![c4alexc4](https://avatars.discourse-cdn.com/v4/letter/c/53a042/32.png) [@c4alexc4](https://discuss.elastic.co/u/c4alexc4)\
**Post date:** [January 23, 2018, 2:23pm UTC](https://discuss.elastic.co/t/writing-to-metadata-with-a-custom-pattern-in-grok/116688/1 "2018-01-23T14:23:50Z")

</div>

Hey,

I have more of a bugreport rather than a question:  
I want to use grok to write data into metadata fields.

While this works with predefined patterns it doesnt work with custom patterns.

Example:

```
%{NUMBER:[@metadata][myNumber]} #this works fine
(?<myNumber>[0-9]{6}) #this works but it obviously doesnt write to @metadata 
(?<[@metadata][myNumber]>[0-9]{6}) #logstash wont even start the pipeline returning weird errors
(?<([@metadata][myNumber])>[0-9]{6}) #doesnt work either, same weird errors

```

Also the config.test\_and\_exit returns OK in all cases! At least the syntax test should be fixed!

Alex

---

<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:** [January 25, 2018, 9:02pm UTC](https://discuss.elastic.co/t/writing-to-metadata-with-a-custom-pattern-in-grok/116688/2 "2018-01-25T21:02:36Z")

</div>

I'd call this a known limitation, but feel free to file a GitHub issue in the logstash-filter-grok project.

---

<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:** [February 22, 2018, 9:02pm UTC](https://discuss.elastic.co/t/writing-to-metadata-with-a-custom-pattern-in-grok/116688/3 "2018-02-22T21:02:55Z")

</div>

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