# Capture specific word from message

**URL:** <https://discuss.elastic.co/t/capture-specific-word-from-message/169180>\
**Category:** Logstash\
**Created:** [February 20, 2019, 10:27am UTC](https://discuss.elastic.co/t/capture-specific-word-from-message/169180 "2019-02-20T10:27:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mancharagopan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mancharagopan/32/60266_2.png) [@mancharagopan](https://discuss.elastic.co/u/mancharagopan)\
**Post date:** [February 20, 2019, 10:27am UTC](https://discuss.elastic.co/t/capture-specific-word-from-message/169180/1 "2019-02-20T10:27:59Z")

</div>

Hi,

I need to create a field with the username from the message. How can i capture the username from a message and put it in a separate field?

Ex:  
`Feb 20 15:23:33 localhost sshd[24958]: Failed password for invalid user admin from 192.168.21.203 port 13246 ssh2`

I need to capture the username which failed to login and put it in a new field.

---

<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 20, 2019, 12:40pm UTC](https://discuss.elastic.co/t/capture-specific-word-from-message/169180/2 "2019-02-20T12:40:46Z")

</div>

How about this?

```
grok { match => { "message" => "invalid user %{WORD:user}" } }
```

---

<div class="post-metadata">

**Author:** ![mancharagopan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mancharagopan/32/60266_2.png) [@mancharagopan](https://discuss.elastic.co/u/mancharagopan)\
**Post date:** [February 20, 2019, 2:22pm UTC](https://discuss.elastic.co/t/capture-specific-word-from-message/169180/3 "2019-02-20T14:22:11Z")

</div>

thanks. that worked

---

<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 20, 2019, 2:34pm UTC](https://discuss.elastic.co/t/capture-specific-word-from-message/169180/4 "2019-03-20T14:34:19Z")

</div>

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