# Extract concrete words with logstash

**URL:** <https://discuss.elastic.co/t/extract-concrete-words-with-logstash/286139>\
**Category:** Logstash\
**Created:** [October 7, 2021, 1:44pm UTC](https://discuss.elastic.co/t/extract-concrete-words-with-logstash/286139 "2021-10-07T13:44:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rodri.gz](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@rodri.gz](https://discuss.elastic.co/u/rodri.gz)\
**Post date:** [October 7, 2021, 1:44pm UTC](https://discuss.elastic.co/t/extract-concrete-words-with-logstash/286139/1 "2021-10-07T13:44:46Z")

</div>

Hi!  
I was interested in knowing if with logstash I could find words that match a pattern and extract them from the message, without parsing the whole message.

For example:

`there has been an error on the **s123s** machine due to a blackout.`

would like from this message to keep the name of the machine when it meet a pre defined pattern but the text is random because is an email so i cant parse the rest of the message because its not static as a log.

Thanks in advance!!

---

<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:** [October 7, 2021, 3:59pm UTC](https://discuss.elastic.co/t/extract-concrete-words-with-logstash/286139/2 "2021-10-07T15:59:37Z")

</div>

You can use grok to match a message against a regexp. There is no need to match the entire message.

---

<div class="post-metadata">

**Author:** ![rodri.gz](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@rodri.gz](https://discuss.elastic.co/u/rodri.gz)\
**Post date:** [October 8, 2021, 7:38am UTC](https://discuss.elastic.co/t/extract-concrete-words-with-logstash/286139/3 "2021-10-08T07:38:38Z")

</div>

> [@rodri.gz](#):
>
> there has been an error on the **s123s** machine due to a blackout.

thank you!! it finally works.

my example :

`there has been an error on the s97bbdd001 machine due to a blackout`

my regular expression: (?[a-zA-Z]\d.{1}....\d.{2})

```auto
[
  {
    "server": "s97bbdd001"
  }
]

```

---

<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:** [November 5, 2021, 7:39am UTC](https://discuss.elastic.co/t/extract-concrete-words-with-logstash/286139/4 "2021-11-05T07:39:35Z")

</div>

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