Hi,
A regular log line from Odoo looks like this:
2023-06-11 19:59:16,264 1 INFO db_tmp werkzeug: 192.168.32.1 - - [11/Jun/2023 19:59:16] "GET /web/assets/190-796b097/web.assets_common_minimal.min.js HTTP/1.0" 404 - 3 0.001 0.002
Which is easy to parse in Loki with the following regex:
(?P<datetime>.+ .+) (?P<userid>\d+) (?P<level>\w+) (?P<database>[a-zA-Z0-9_?]+) (?P<process>[a-zA-Z\._]+): (?P<message>.*)
Now a traceback looks like this:
2023-06-11 19:59:16,277 1 INFO db_tmp odoo.addons.base.models.ir_attachment: _read_file reading /var/lib/odoo/.local/share/Odoo/filestore/db_tmp/0e/0ee951439c6eb9f6df65166aa4dda9b8351ecd0e
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/api.py", line 886, in get
return field_cache[record._ids[0]]
KeyError: 191
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1082, in __get__
value = env.cache.get(record, self)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 889, in get
raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: 'ir.attachment(191,).datas'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/api.py", line 886, in get
return field_cache[record._ids[0]]
KeyError: 191
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/fields.py", line 1082, in __get__
value = env.cache.get(record, self)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 889, in get
raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: 'ir.attachment(191,).raw'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_attachment.py", line 119, in _file_read
with open(full_path, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/odoo/.local/share/Odoo/filestore/db_tmp/0e/0ee951439c6eb9f6df65166aa4dda9b8351ecd0e'
Apparently this aggregation can only be done via the Promtail configuration.
Of course I read the documentation here: https://grafana.com/docs/loki/latest/clients/promtail/stages/multiline/
Then I tried this configuration which doesn’t aggregate anything:
- job_name: odoo
pipeline_stages:
- multiline:
firstline: '^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{1,3}'
max_wait_time: 3s
max_lines: 500
- regex:
expression: '^(?P<datetime>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{1,3})(?P<message>(?s:.*))$'
- timestamp:
source: datetime
format: "2006-01-02 15:04:05,999999999Z"
I tried with various other values for these parameters, quite randomly, to no avail.
Based on the log sample I showed above, can anybody point me in the right direction.
Thanks a lot.