|
Packit |
62eeb0 |
# container-exception-logger
|
|
Packit |
62eeb0 |
A tool designed to run inside of a container which is able to get its input
|
|
Packit |
62eeb0 |
outside of the container.
|
|
Packit |
62eeb0 |
|
|
Packit |
62eeb0 |
This tool was created because there was not possible to get any information
|
|
Packit |
62eeb0 |
outside of a container. The tool is mainly used by interpreter's default hooks
|
|
Packit |
62eeb0 |
to pass unhandled exceptions to a host for further analysis.
|
|
Packit |
62eeb0 |
|
|
Packit |
62eeb0 |
## Format specification
|
|
Packit |
62eeb0 |
It's possible to use whatever format of a message you want.
|
|
Packit |
62eeb0 |
Openshift logging system (fluentd) and ABRT use
|
|
Packit |
62eeb0 |
JSON. For this reason, we recommend using JSON too.
|
|
Packit |
62eeb0 |
|
|
Packit |
62eeb0 |
### Mandatory elements
|
|
Packit |
62eeb0 |
Tools which parse container-exception-logger messages expecting the messages
|
|
Packit |
62eeb0 |
contain following elements:
|
|
Packit |
62eeb0 |
* `type`: string - exception type - Python, Python3, Ruby, etc.
|
|
Packit |
62eeb0 |
* `executable`: string - executable which caused the problem
|
|
Packit |
62eeb0 |
* `reason`: string - reason of the problem
|
|
Packit |
62eeb0 |
* `backtrace`: string - backtrace of the problem
|
|
Packit |
62eeb0 |
* `time`: int - seconds since 1970-01-01 00:00:00 UTC
|
|
Packit |
62eeb0 |
|
|
Packit |
62eeb0 |
### Optional elements
|
|
Packit |
62eeb0 |
Additional elements can be added without any limitation. For instance `pid`,
|
|
Packit |
62eeb0 |
`uid`, `msg`, etc.
|
|
Packit |
62eeb0 |
|
|
Packit |
62eeb0 |
Example of a message:
|
|
Packit |
62eeb0 |
```
|
|
Packit |
62eeb0 |
{"type": "Python3", "executable": "/usr/bin/will_python3_raise", "reason": "will_python3_raise:3:<module>:ZeroDivisionError: division by zero", "backtrace": "will_python3_raise:3:<module>:ZeroDivisionError: division by zero\n\nTraceback (most recent call last):\n File \"/usr/bin/will_python3_raise\", line 3, in <module>\n 0/0\nZeroDivisionError: division by zero\n\nLocal variables in innermost frame:\n__name__: '__main__'\n__doc__: None\n__package__: None\n__loader__: <_frozen_importlib_external.SourceFileLoader object at 0x7fc4568a9780>\n__spec__: None\n__annotations__: {}\n__builtins__: <module 'builtins' (built-in)>\n__file__: '/usr/bin/will_python3_raise'\n__cached__: None\n", "time": 1521454815, "pid": 23}
|
|
Packit |
62eeb0 |
```
|
|
Packit |
62eeb0 |
|
|
Packit |
62eeb0 |
## How to use container-exception-logger
|
|
Packit |
62eeb0 |
**container-exception-logger** - log from a container to a host
|
|
Packit |
62eeb0 |
|
|
Packit |
62eeb0 |
Usage: `container-exception-logger [--no-tag | --tag TAG | --help]`
|
|
Packit |
62eeb0 |
|
|
Packit |
62eeb0 |
**Parameters:**
|
|
Packit |
62eeb0 |
|
|
Packit |
62eeb0 |
`--no-tag` - do not tag a message in logs
|
|
Packit |
62eeb0 |
|
|
Packit |
62eeb0 |
`--tag` - change tag of a message in logs (defaults: 'container-exception-logger')
|
|
Packit |
62eeb0 |
|
|
Packit |
62eeb0 |
**Example of usage:**
|
|
Packit |
62eeb0 |
|
|
Packit |
62eeb0 |
For better illustration variable MSG contains a message from previous capture 'Format specification'.
|
|
Packit |
62eeb0 |
```
|
|
Packit |
62eeb0 |
Container:
|
|
Packit |
62eeb0 |
$ echo $MSG | container-exception-logger
|
|
Packit |
62eeb0 |
Host's log:
|
|
Packit |
62eeb0 |
Mar 19 14:59:04 localhost.localdomain dockerd-current[981]: container-exception-logger - $MSG
|
|
Packit |
62eeb0 |
|
|
Packit |
62eeb0 |
Container:
|
|
Packit |
62eeb0 |
$ echo $MSG | container-exception-logger --no-tag
|
|
Packit |
62eeb0 |
Host's log:
|
|
Packit |
62eeb0 |
Mar 19 15:00:27 localhost.localdomain dockerd-current[981]: $MSG
|
|
Packit |
62eeb0 |
|
|
Packit |
62eeb0 |
Container:
|
|
Packit |
62eeb0 |
$ echo $MSG | container-exception-logger --tag new-tag
|
|
Packit |
62eeb0 |
Host's log:
|
|
Packit |
62eeb0 |
Mar 19 15:00:27 localhost.localdomain dockerd-current[981]: new-tag - $MSG
|
|
Packit |
62eeb0 |
```
|