# Additional field with special data

**URL:** <https://discuss.elastic.co/t/additional-field-with-special-data/48304>\
**Category:** Logstash\
**Created:** [April 25, 2016, 10:54am UTC](https://discuss.elastic.co/t/additional-field-with-special-data/48304 "2016-04-25T10:54:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![darkelf](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@darkelf](https://discuss.elastic.co/u/darkelf)\
**Post date:** [April 25, 2016, 10:54am UTC](https://discuss.elastic.co/t/additional-field-with-special-data/48304/1 "2016-04-25T10:54:24Z")

</div>

Hello,  
I'm new with elk and want set up an elk stack for varnish logs.  
My logstash filter setup looks like this:

> filter {  
> if [type] == "varnish" {  
> grok {  
> patterns\_dir =\> ["/etc/logstash/patterns"]  
> match =\> {  
> "message" =\> ["(?:%{IPV4:client\_ip}|%{IPV4:client\_ip}, %{IPV4:lb\_ip}) %{USER:user} [%{VARNISHDATE}] "%{WORD:method} %{NOTSPACE:request\_page} HTTP/%{NUMBER:http\_version}" %{NUMBER:server\_response} %{NUMBER:bytes} (?:%{QS:referrer}| -) %{QS:useragent}" ]  
> }  
> }  
> } else ...

Several virtual Hosts are configured at the backend of varnish.

The request\_page field contains the protocol and the hole URL string. How do I extract the request Domain from the request\_page field and put it in an new field?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [April 25, 2016, 7:57pm UTC](https://discuss.elastic.co/t/additional-field-with-special-data/48304/2 "2016-04-25T19:57:55Z")

</div>

> The request\_page field contains the protocol and the hole URL string. How do I extract the request Domain from the request\_page field and put it in an new field?

Do you still want to keep the `request_page` field?

If yes, use a second grok filter to extract the domain. The standard grok patterns contain a bunch of URL-related patterns that you might find useful. (That said, it's probably possible to extract both the whole request and just the domain in a single expression.)

If no, don't use NOTSPACE; use a more exact pattern that only extracts the domain.

---

<div class="post-metadata">

**Author:** ![darkelf](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@darkelf](https://discuss.elastic.co/u/darkelf)\
**Post date:** [April 26, 2016, 6:48am UTC](https://discuss.elastic.co/t/additional-field-with-special-data/48304/3 "2016-04-26T06:48:46Z")

</div>

I do this:

```
                grok {
                        patterns_dir => ["/etc/logstash/patterns"]
                        match => { "message" => ["(?:%{IPV4:client_ip}|%{IPV4:client_ip}, %{IPV4:lb_ip}) %{USER:user} \[%{VARNISHDATE}\] \"%{WORD:method} %{NOTSPACE:request_page} HTTP/%{NUMBER:http_version}\" %{NUMBER:server_response} %{NUMBER:bytes} (?:%{QS:referrer}| -) %{QS:useragent}" ] }
                        match => { "request_page" => "%{URIPROTO}://%{HOSTNAME:domain}" }
                        break_on_match => false
                }

```

and I will think about mor exact pattern.

Thank you very much

---

<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, 5:00am UTC](https://discuss.elastic.co/t/additional-field-with-special-data/48304/4 "2017-07-06T05:00:34Z")

</div>


