# Create index from the the grok pattern output

**URL:** <https://discuss.elastic.co/t/create-index-from-the-the-grok-pattern-output/167119>\
**Category:** Logstash\
**Created:** [February 5, 2019, 12:30pm UTC](https://discuss.elastic.co/t/create-index-from-the-the-grok-pattern-output/167119 "2019-02-05T12:30:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kolli\_dilip](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kolli_dilip/32/33821_2.png) [@kolli\_dilip](https://discuss.elastic.co/u/kolli_dilip)\
**Post date:** [February 5, 2019, 12:30pm UTC](https://discuss.elastic.co/t/create-index-from-the-the-grok-pattern-output/167119/1 "2019-02-05T12:30:50Z")

</div>

Hi

I have a requirement of creating the index based on the filed in the message

for example my grok is as below

(?:%{WORD:method}|-)(?:%{NOTSPACE:Appname}|-)

so in my message i have a set of Appname's, so i need to index the data into ES as per the Appname , so is there any way i can do this

Thanks

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [February 5, 2019, 12:52pm UTC](https://discuss.elastic.co/t/create-index-from-the-the-grok-pattern-output/167119/2 "2019-02-05T12:52:43Z")

</div>

Yes, you can use a "[sprintf](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html)" reference to the application name.

```
output {
    elasticsearch {
        index => "%{Appname}"
        ...
    }
}

```

Just be aware that having a large number of small indexes adds a lot of performance overhead. But if you only have a small number of values for Appname this should be OK.

---

<div class="post-metadata">

**Author:** ![kolli\_dilip](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kolli_dilip/32/33821_2.png) [@kolli\_dilip](https://discuss.elastic.co/u/kolli_dilip)\
**Post date:** [February 6, 2019, 8:46am UTC](https://discuss.elastic.co/t/create-index-from-the-the-grok-pattern-output/167119/3 "2019-02-06T08:46:12Z")

</div>

Thank you @Badger for this

Can i know why uppercase letters are not allowed for creating index??

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [February 6, 2019, 1:16pm UTC](https://discuss.elastic.co/t/create-index-from-the-the-grok-pattern-output/167119/4 "2019-02-06T13:16:42Z")

</div>

> [@kolli\_dilip](#):
>
> Can i know why uppercase letters are not allowed for creating index??

That would be an elasticsearch question, not a logstash question.

---

<div class="post-metadata">

**Author:** ![kolli\_dilip](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kolli_dilip/32/33821_2.png) [@kolli\_dilip](https://discuss.elastic.co/u/kolli_dilip)\
**Post date:** [February 7, 2019, 9:24am UTC](https://discuss.elastic.co/t/create-index-from-the-the-grok-pattern-output/167119/5 "2019-02-07T09:24:48Z")

</div>

so now i need to add a condition here that if its a specific Appname that has uppercase in it, it has to be indexed as default logstash-\* and if its a lower case then it has to be the index as index =\> "%{Appname}"

any option for this ?

---

<div class="post-metadata">

**Author:** ![kolli\_dilip](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kolli_dilip/32/33821_2.png) [@kolli\_dilip](https://discuss.elastic.co/u/kolli_dilip)\
**Post date:** [February 7, 2019, 1:43pm UTC](https://discuss.elastic.co/t/create-index-from-the-the-grok-pattern-output/167119/6 "2019-02-07T13:43:04Z")

</div>

I just mutated every thing with lowercase to avoid index failure 🙂

---

<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:** [March 7, 2019, 1:48pm UTC](https://discuss.elastic.co/t/create-index-from-the-the-grok-pattern-output/167119/7 "2019-03-07T13:48:37Z")

</div>

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