# Grok until first period

**URL:** <https://discuss.elastic.co/t/grok-until-first-period/193909>\
**Category:** Logstash\
**Created:** [August 6, 2019, 3:05am UTC](https://discuss.elastic.co/t/grok-until-first-period/193909 "2019-08-06T03:05:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![uklipse](https://avatars.discourse-cdn.com/v4/letter/u/cdc98d/32.png) [@uklipse](https://discuss.elastic.co/u/uklipse)\
**Post date:** [August 6, 2019, 3:05am UTC](https://discuss.elastic.co/t/grok-until-first-period/193909/1 "2019-08-06T03:05:45Z")

</div>

Hi, new to creating parsing rules so bear with me. I need to parse up until the first period but can't seem to make it work. Below is what I'm trying to parse.

GlobalProtect gateway user authentication succeeded. Login from: 1.2.3.4

I've tried various forms of %{GREEDYDATA}. but I it seems to only go to the last period and not the first. If I set it as %{GREEDYDATA}: it works to the only colon but just need some help when there are multiples of a character.

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:** [August 6, 2019, 12:11pm UTC](https://discuss.elastic.co/t/grok-until-first-period/193909/2 "2019-08-06T12:11:10Z")

</div>

Use a custom pattern that explicitly matches anything except a period followed by a period.

```
grok { match => { "message" => "^(?<someField>[^\.]+)\." } }
```

---

<div class="post-metadata">

**Author:** ![uklipse](https://avatars.discourse-cdn.com/v4/letter/u/cdc98d/32.png) [@uklipse](https://discuss.elastic.co/u/uklipse)\
**Post date:** [August 6, 2019, 2:13pm UTC](https://discuss.elastic.co/t/grok-until-first-period/193909/3 "2019-08-06T14:13:49Z")

</div>

Great, that did it!

I'm trying to figure out why this works and from the documentation I think sequence [^.]+means the [] match a single character which the ^ negates what follows which is a period (slash because of special character). So it says give me the start of the string up to the . but leave off the period but I'm not sure how the + comes into play. Any insight?

---

<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:** [August 6, 2019, 2:42pm UTC](https://discuss.elastic.co/t/grok-until-first-period/193909/4 "2019-08-06T14:42:24Z")

</div>

[] is a character group. In this case any character except . The + means one or more of the members of the character group.

---

<div class="post-metadata">

**Author:** ![uklipse](https://avatars.discourse-cdn.com/v4/letter/u/cdc98d/32.png) [@uklipse](https://discuss.elastic.co/u/uklipse)\
**Post date:** [August 6, 2019, 6:05pm UTC](https://discuss.elastic.co/t/grok-until-first-period/193909/5 "2019-08-06T18:05:10Z")

</div>

Thanks, appreciate that!

---

<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:** [September 3, 2019, 6:05pm UTC](https://discuss.elastic.co/t/grok-until-first-period/193909/6 "2019-09-03T18:05:11Z")

</div>

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