# Output Wildcard for Hostname

**URL:** <https://discuss.elastic.co/t/output-wildcard-for-hostname/173222>\
**Category:** Logstash\
**Created:** [March 20, 2019, 8:40pm UTC](https://discuss.elastic.co/t/output-wildcard-for-hostname/173222 "2019-03-20T20:40:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![teamg](https://avatars.discourse-cdn.com/v4/letter/t/e19b73/32.png) [@teamg](https://discuss.elastic.co/u/teamg)\
**Post date:** [March 20, 2019, 8:40pm UTC](https://discuss.elastic.co/t/output-wildcard-for-hostname/173222/1 "2019-03-20T20:40:08Z")

</div>

This code works:

> output {  
> if [host][name] in ["[lab4a.local.com](http://lab4a.local.com)", "[lab4b.local.com](http://lab4b.local.com)"] {  
> elasticsearch {  
> index =\> "lab4-%{+YYYY.MM.dd}"  
> }  
> }  
> }

Because I have multiple hosts with the hostname lab4{a,b,c,d,e...z} it'd be simpler if I could use a wildcard in the hostname, for example  
output {

> if [host][name] in ["lab4\*"] {  
> elasticsearch {  
> index =\> "lab4-%{+YYYY.MM.dd}"  
> }  
> }  
> }

The asterisk does work so I tried regex:

> if [host][name] in ["lab4\w.\*"]

but no luck either. What is the best way to use wildcards in this situation?

---

<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:** [March 20, 2019, 9:49pm UTC](https://discuss.elastic.co/t/output-wildcard-for-hostname/173222/2 "2019-03-20T21:49:35Z")

</div>

```
if [host][name] =~ /^lab4*/
```

---

<div class="post-metadata">

**Author:** ![teamg](https://avatars.discourse-cdn.com/v4/letter/t/e19b73/32.png) [@teamg](https://discuss.elastic.co/u/teamg)\
**Post date:** [March 22, 2019, 2:26pm UTC](https://discuss.elastic.co/t/output-wildcard-for-hostname/173222/3 "2019-03-22T14:26:58Z")

</div>

This worked for me. Thank you once again @Badger.

---

<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:** [April 19, 2019, 2:27pm UTC](https://discuss.elastic.co/t/output-wildcard-for-hostname/173222/4 "2019-04-19T14:27:08Z")

</div>

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