Feature request: Add ECS compatibility
Henkhogan opened this issue · 3 comments
Add a constant dictionary that can be used in order to map the python logger fields to ecs (https://www.elastic.co/guide/en/ecs/current/ecs-reference.html) compatible field names
JSONLOGGER_RENAME_FIELDS_ECS = {
'levelname':'log.level',
'funcName': 'log.origin.function',
'module': 'log.origin.file.name',
'name': 'log.logger',
'process': 'process.pid',
'processName': 'process.name',
'thread': 'process.thread.id',
'threadName': 'process.thread.name'
}
that can then be used like
json_formatter = jsonlogger.JsonFormatter(rename_fields = JSONLOGGER_RENAME_FIELDS_ECS)
Hey @Henkhogan
Why this map should be packaged in python-json-logger
? It looks like you found the solution to make things work locally.
Having a such map in this package would mean that it has to be maintained. In addition to this, this is Cloud provider-specific, so this is specific to your use case and not to the use case of users of this library. I don't think such addition makes sense for the community IMHO.
Hey @louis-jaris,
I think ECS is not cloud provider specific but supposed to be an open standard for logging.
Furthermore the map is expected to be static. It only maps the field names that the python logger has built in.
However if you have a problem maintaining the map, I will remove it from the PR and just keep the other change in.
Just let me know.
Cheers
Changes merged. please open a new issue if something isn't working