7. Odoo configuration - Alexandre-Guth/Elastic-Stack-FileBeat-Logspout GitHub Wiki
Work in progress
The set up
Odoo is installed in containers within a rancher environment. To do so, 2 dedicated nginx and postgres containers are deployed. Getting logs from containers could be tricky, we also used syslog-ng container and a filebeat container as sidekicks
Containers
This is a sample of our docker-compose, it is not complete and just highlight the most important variables:
nginx
volumes:
- /srv/log/nginx10:/var/log/nginx
environment:
HTTPS_REDIRECT: 'true'
RESTRICTED_ADMIN_AREA: 'false'
postgres
volumes:
- /srv/odoo10/postgres/data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: password
odoo
labels:
io.rancher.sidekicks: syslog-ng2,filebeat
volumes:
- syslog:/var/log
environment:
PSQL_HOST: postgres
PSQL_PORT: '5555'
PSQL_USER: username
PSQL_USER_PASS: password
GIT_BRANCH: '10.0'
filebeat
volumes:
- syslog:/var/log/odoo
syslog-ng
volumes_from:
- odoo
Getting the Odoo logs
The best option would be to configure odoo to log directly to syslog-ng or rsyslog and then ship the logs directly to Logstash. Unfortunately, I lacked of time to do it so I came up with a working configuration that was quicker to set up:
Add the followings to Odoo configuration file:
syslog = True
logfile = /path/to/odoo.log
Set up syslog-ng configuration file /etc/syslog-ng/syslog-ng.conf
Filebeat source the log from the odoo log file:
and ship it to Logstash:
https://github.com/Alexandre-Guth/Elastic-Stack-FileBeat-Logspout/blob/master/FileBeat/filebeat.yml
Parse the Odoo logs
Here are the grok filters to parse standard Odoo logs:
https://github.com/Alexandre-Guth/Elastic-Stack-FileBeat-Logspout/blob/master/Logstash/30_odoo.conf
Unfortunately, Odoo logs are not formatted the same way in debug mode so you won't receive any logs in Elasticsearch with this configuration. You can buil dyour own filters with the help of the documentation and tools as this grok pattern matcher:
http://grokconstructor.appspot.com/do/match
There is also a grok debugger in the dev tools menu of Kibana;
We are still working on a better integration of the Odoo logs and I will update the wiki as soon as we'll get satisfying results.