# Grok path matching

**URL:** <https://discuss.elastic.co/t/grok-path-matching/51476>\
**Category:** Logstash\
**Created:** [May 31, 2016, 7:30pm UTC](https://discuss.elastic.co/t/grok-path-matching/51476 "2016-05-31T19:30:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mightyschwartz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mightyschwartz/32/10007_2.png) [@mightyschwartz](https://discuss.elastic.co/u/mightyschwartz)\
**Post date:** [May 31, 2016, 7:30pm UTC](https://discuss.elastic.co/t/grok-path-matching/51476/1 "2016-05-31T19:30:23Z")

</div>

When I define a grok pattern for windows file path matching, I cannot get it to work... even with the default.

The log is as follows:

```
{
       "message" => "Prepared StagingJob for spreadsheet 'C:\\App\\Folder\\test_2.xlsx'\r",
      "@version" => "1",
    "@timestamp" => "2016-05-31T19:25:24.274Z",
          "path" => "/mnt/logs/SchedulerService.log",
          "host" => "elastic",
          "tags" => [
        [0] "_grokparsefailure"
    ],
      "filename" => ""
}

```

My filter is as such:

```
 filter {
   grok {
     patterns_dir => ["/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-patterns-core-2.0.5/patterns"]
     match => { "message" => "%{SCHED_EXCEL}" }
     match => { "message" => "%{SCHED_FILENAME}" }
   }

```

My Grok Pattern is as follows:

`SCHED_FILENAME ^Prepared StagingJob for spreadsheet '%{WINPATHTEST:filename}'(\\r*)`

WINPATHTEST is:

`WINPATHTEST [a-zA-Z]:(\\[A-Za-z0-9\-,_\(\)]*)+\.[A-Za-z0-9]+`

I've tried using WINPATH, but that failed as well. I've verified that this works in grok constructor at [http://grokconstructor.appspot.com/do/match](http://grokconstructor.appspot.com/do/match)

Regards,

Jimmy

---

<div class="post-metadata">

**Author:** ![msimos](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@msimos](https://discuss.elastic.co/u/msimos)\
**Post date:** [May 31, 2016, 8:06pm UTC](https://discuss.elastic.co/t/grok-path-matching/51476/2 "2016-05-31T20:06:09Z")

</div>

Hi,

Have you tried using WINPATH. Take a look at these grok patterns:

> <https://github.com/logstash-plugins/logstash-patterns-core/blob/master/patterns/grok-patterns#L36>

---

<div class="post-metadata">

**Author:** ![mightyschwartz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mightyschwartz/32/10007_2.png) [@mightyschwartz](https://discuss.elastic.co/u/mightyschwartz)\
**Post date:** [May 31, 2016, 8:07pm UTC](https://discuss.elastic.co/t/grok-path-matching/51476/3 "2016-05-31T20:07:46Z")

</div>

Yes. I have WINPATH in my original post. 🙂

---

<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:** [July 6, 2017, 4:55am UTC](https://discuss.elastic.co/t/grok-path-matching/51476/4 "2017-07-06T04:55:09Z")

</div>


