# Parsing logs from Dockerized NGinx

**URL:** <https://discuss.elastic.co/t/parsing-logs-from-dockerized-nginx/198274>\
**Category:** Logstash\
**Created:** [September 5, 2019, 2:40pm UTC](https://discuss.elastic.co/t/parsing-logs-from-dockerized-nginx/198274 "2019-09-05T14:40:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JamesRamm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jamesramm/32/53652_2.png) [@JamesRamm](https://discuss.elastic.co/u/JamesRamm)\
**Post date:** [September 5, 2019, 2:40pm UTC](https://discuss.elastic.co/t/parsing-logs-from-dockerized-nginx/198274/1 "2019-09-05T14:40:42Z")

</div>

Hi

I am trying to use the ELK stack to view & index logs from a bunch of services running in docker containers. One such service is NGinX and I would like to start with this.

I have deployed filebeat, logstash, elasticsearch & kibana with docker & docker-compose.  
I am successfully harvesting all docker logs using filebeat (which is adding docker metadata), which is forwarding them to logstash (currently not really doing anything) and elasticsearch.

So in Kibana I can see something like this:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/a/baacecd4c5e2ddf0da89c64a5fd2452ea86c91ed.png)

What I would like to do is parse and index log messages from the nginx container, which can be identified by name.

My first thought is that I should be using logstash to extract the nginx message from the docker json log and then parse this.

- Is this possible?
- Is this correct, or should I be using only filebeat or doing something else?

My filebeat configuration looks like this:

```
filebeat.inputs:
- type: container
  paths:
  - '/var/lib/docker/containers/*/*.log'

processors:
  - add_docker_metadata:
      host: "unix:///var/run/docker.sock"

output.logstash:
  hosts: ["logstash:5044"]

```

And logstash config is currently not very interesting:

```
input {
	beats {
		port => 5044
      host => "0.0.0.0"
	}
}

## Add your filters / logstash plugins configuration here

output {
	elasticsearch {
		hosts => ["elasticsearch:9200"]
	}
}
```

---

<div class="post-metadata">

**Author:** ![JamesRamm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jamesramm/32/53652_2.png) [@JamesRamm](https://discuss.elastic.co/u/JamesRamm)\
**Post date:** [September 6, 2019, 11:43am UTC](https://discuss.elastic.co/t/parsing-logs-from-dockerized-nginx/198274/2 "2019-09-06T11:43:07Z")

</div>

I added a grok filter in the logstash.conf:

grok {  
match =\> {"message" =\> "%{IPORHOST:remote\_ip} - %{DATA:user\_name} [%{HTTPDATE:access\_time}] "%{WORD:http\_method} %{DATA:url} HTTP/%{NUMBER:http\_version}" %{NUMBER:response\_code} %{NUMBER:body\_sent\_bytes} "%{DATA:referrer}" "%{DATA:agent}""}  
}

It catches access mesasges, but [notice] messages from nginx itself are a different format.

---

<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:** [October 4, 2019, 11:58am UTC](https://discuss.elastic.co/t/parsing-logs-from-dockerized-nginx/198274/3 "2019-10-04T11:58:00Z")

</div>

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