# Grok pattern with forward slashes result in grokfailure

**URL:** <https://discuss.elastic.co/t/grok-pattern-with-forward-slashes-result-in-grokfailure/143362>\
**Category:** Logstash\
**Created:** [August 7, 2018, 3:28pm UTC](https://discuss.elastic.co/t/grok-pattern-with-forward-slashes-result-in-grokfailure/143362 "2018-08-07T15:28:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmcazaux](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jmcazaux/32/45749_2.png) [@jmcazaux](https://discuss.elastic.co/u/jmcazaux)\
**Post date:** [August 7, 2018, 3:28pm UTC](https://discuss.elastic.co/t/grok-pattern-with-forward-slashes-result-in-grokfailure/143362/1 "2018-08-07T15:28:26Z")

</div>

Hi there,

I am trying to extract path components from a "path-like" string and it fails with grokfailure.

I have been banding my head on walls for houyrs with this. It works in "Grok Debugger", but fails in Logstash.

My data looks like this:  
`/project-name/app-name/dev/source-name`

My pattern is:  
`/%{GREEDYDATA:project}/%{GREEDYDATA:application}/%{GREEDYDATA:env}/%{GREEDYDATA:source}`

Many thanks in advance for your help,  
JM

---

<div class="post-metadata">

**Author:** ![waqark3389](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waqark3389/32/34265_2.png) [@waqark3389](https://discuss.elastic.co/u/waqark3389)\
**Post date:** [August 7, 2018, 4:19pm UTC](https://discuss.elastic.co/t/grok-pattern-with-forward-slashes-result-in-grokfailure/143362/2 "2018-08-07T16:19:47Z")

</div>

This should work as I use a similar method - can you post the full config?

Also try this:

> (?:/%{GREEDYDATA:project}/%{GREEDYDATA:application}/%{GREEDYDATA:env}/%{GREEDYDATA:source})

As this is the exact thing I have in my config and is working!

---

<div class="post-metadata">

**Author:** ![jmcazaux](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jmcazaux/32/45749_2.png) [@jmcazaux](https://discuss.elastic.co/u/jmcazaux)\
**Post date:** [August 7, 2018, 4:27pm UTC](https://discuss.elastic.co/t/grok-pattern-with-forward-slashes-result-in-grokfailure/143362/3 "2018-08-07T16:27:50Z")

</div>

I tried your example and it did not work.

Can you please clarify what you mean by _the full config_?

Here is my filter:

> ```
> grok {
> keep_empty_captures => "true"
> match => { "cloudwatch_logs.log_group" => "(?:/%{GREEDYDATA:project}/%{GREEDYDATA:application}/%{GREEDYDATA:env}/%{GREEDYDATA:source})"}
> }
> 
> ```

As well, we are writing logs to AWS Cloudwatch from the application and reading it from the Cloudwatch pluggin in Logstash.

Th name of the log group contains "meta" about the app.

---

<div class="post-metadata">

**Author:** ![waqark3389](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waqark3389/32/34265_2.png) [@waqark3389](https://discuss.elastic.co/u/waqark3389)\
**Post date:** [August 7, 2018, 4:36pm UTC](https://discuss.elastic.co/t/grok-pattern-with-forward-slashes-result-in-grokfailure/143362/4 "2018-08-07T16:36:03Z")

</div>

You are using cloudwatch\_logs.log\_group, should this not be: [cloudwatch\_logs][log\_group]  
Im not too familiar with cloudwatch input though.

---

<div class="post-metadata">

**Author:** ![jmcazaux](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jmcazaux/32/45749_2.png) [@jmcazaux](https://discuss.elastic.co/u/jmcazaux)\
**Post date:** [August 8, 2018, 11:49am UTC](https://discuss.elastic.co/t/grok-pattern-with-forward-slashes-result-in-grokfailure/143362/5 "2018-08-08T11:49:20Z")

</div>

Completely missed this

Using [cloudwatch\_logs][log\_group] was indeed the solution.

Many thanks for this,  
JM

---

<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 5, 2018, 11:49am UTC](https://discuss.elastic.co/t/grok-pattern-with-forward-slashes-result-in-grokfailure/143362/6 "2018-09-05T11:49:23Z")

</div>

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