# Nested grok on custom syslogs of vernish servers

**URL:** <https://discuss.elastic.co/t/nested-grok-on-custom-syslogs-of-vernish-servers/130137>\
**Category:** Logstash\
**Created:** [May 1, 2018, 5:15pm UTC](https://discuss.elastic.co/t/nested-grok-on-custom-syslogs-of-vernish-servers/130137 "2018-05-01T17:15:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ferdous\_Shibly](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ferdous_shibly/32/23470_2.png) [@Ferdous\_Shibly](https://discuss.elastic.co/u/Ferdous_Shibly)\
**Post date:** [May 1, 2018, 5:15pm UTC](https://discuss.elastic.co/t/nested-grok-on-custom-syslogs-of-vernish-servers/130137/1 "2018-05-01T17:15:06Z")

</div>

Hi,

I am trying to process custom access logs of vernish servers. The log format is:

> %h %t %r %\>s %b %{resp.http.X-Cache}V %{req.http.user-agent}V %{req.http.referer}V %{geoip.city}V

Here is a sample logs:

> Mar 25 09:57:33 X VerticalAlfa X\<134\>2018-03-25T13:57:32Z cache-scl19420 VerticalAlfa\_syslog[28479]: 190.233.180.138 [25/Mar/2018:13:47:30 +0000] POST /diez-platos-fundamentales-de-la-cocina-peruana-1190601?url=https%3A%2F%[2Fwww.VerticalAlfa.com](http://2Fwww.VerticalAlfa.com)%2Fdiez-platos-fundamentales-de-la-cocina-peruana-1190601 HTTP/1.1 503 “-” MISS Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36 [https://www.VerticalAlfa.com/diez-platos-fundamentales-de-la-cocina-peruana-1190601](https://www.VerticalAlfa.com/diez-platos-fundamentales-de-la-cocina-peruana-1190601) Lima

How do we extract all the field in Logstash?

Here is the logstash filter configuration

```
> filter {
> 
> grok {
> match => {
> "message" => "%{CISCOTIMESTAMP} X %{WORD:vertical} X%{SYSLOG5424PRI}%{SYSLOGLINE}"
> if ("" in [message]) {
> grok {
> match => {
> "message" => "%{IPORHOST:clientip} %{SYSLOG5424SD} %{WORD:verb} %{URIPATHPARAM} HTTP/%{NUMBER:httpversion} %{DATA:reques:int} (?:-|%{NUMBER:bytes:int}) %{WORD:varnish_hierarchy_status} %{QS:referrer} %{QS:agent} %{URI} %{WORD:city}"
> }
> }
> }
> }
> }
>
> }

```

But it is not matching any logs. Please help.

Cheers  
Ferdous Shibly

---

<div class="post-metadata">

**Author:** ![yaauie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaauie/32/23363_2.png) [@yaauie](https://discuss.elastic.co/u/yaauie)\
**Post date:** [May 1, 2018, 9:48pm UTC](https://discuss.elastic.co/t/nested-grok-on-custom-syslogs-of-vernish-servers/130137/2 "2018-05-01T21:48:12Z")

</div>

The pasted configuration won't compile -- we cannot embed plugins inside of other plugins.

Instead, we typically _chain_ the plugins, using each to extract the information needed by the ones that follow it:

```auto
filter {
  grok {
    match => {
      "message" => "%{CISCOTIMESTAMP} X %{WORD:vertical} X%{SYSLOG5424PRI}${GREEDYDATA:[@metadata][syslog_line]}"
    }
  }
  # if that succeeded, continue parsing from the value we placed in `[@metadata][syslog_line]`:
  if "_grokparsefailure" not in [tags] {
    grok {
      match => {
        "[@metadata][syslog_line]" => "%{IPORHOST:clientip} %{SYSLOG5424SD} %{WORD:verb} %{URIPATHPARAM} HTTP/%{NUMBER:httpversion} %{DATA:reques:int} (?:-|%{NUMBER:bytes:int}) %{WORD:varnish_hierarchy_status} %{QS:referrer} %{QS:agent} %{URI} %{WORD:city}"
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![Ferdous\_Shibly](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ferdous_shibly/32/23470_2.png) [@Ferdous\_Shibly](https://discuss.elastic.co/u/Ferdous_Shibly)\
**Post date:** [May 2, 2018, 6:02am UTC](https://discuss.elastic.co/t/nested-grok-on-custom-syslogs-of-vernish-servers/130137/3 "2018-05-02T06:02:32Z")

</div>

> [@Ferdous\_Shibly](#):
>
> Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36

@yaauie Thanks fro your help. I can't process

> Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36

with %{QS:referrer} %{QS:agent}. Is there any other way?

---

<div class="post-metadata">

**Author:** ![yaauie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaauie/32/23363_2.png) [@yaauie](https://discuss.elastic.co/u/yaauie)\
**Post date:** [May 2, 2018, 6:25am UTC](https://discuss.elastic.co/t/nested-grok-on-custom-syslogs-of-vernish-servers/130137/4 "2018-05-02T06:25:44Z")

</div>

You may want to use the Grok Constructor, a tool for building patterns, using a variety of input lines.

---

<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:** [May 30, 2018, 6:25am UTC](https://discuss.elastic.co/t/nested-grok-on-custom-syslogs-of-vernish-servers/130137/5 "2018-05-30T06:25:47Z")

</div>

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