Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding event.dataset field per event #119

Open
HaloFour opened this issue Jan 7, 2021 · 2 comments
Open

Allow overriding event.dataset field per event #119

HaloFour opened this issue Jan 7, 2021 · 2 comments
Labels
agent-java community Issues and PRs created by the community

Comments

@HaloFour
Copy link
Contributor

HaloFour commented Jan 7, 2021

Currently the EcsLayout class in log4j2-ecs-layout defaults the event.dataset to the service name + ".log". At most we can override it with a specific value, but that specific value will be written for every log line.

In the project I am working on we are generating multiple kinds of events into a single log file, including access, egress, trace and logs. We want to be able to differentiate these events by the event.dataset field as required by an internal observability team but we can't set/override that field per event. If we set it in ContextData/MDC manually it causes the field to be written twice.

I can understand trying to negotiate the event context data per event before writing out standard fields might be opening a can of worms but I'd like to have the conversation as to how situations like this could be handled.

@felixbarny
Copy link
Member

Hi and thanks for the issue. Would it help you to have the ability to disable writing a default event.dataset so that the value from MDC is the only one?
I'm not actually sure what happens when you have the same key multiple times. Does the JSON parsing fail or does the last value win?

@HaloFour
Copy link
Contributor Author

Would it help you to have the ability to disable writing a default event.dataset so that the value from MDC is the only one?

Yes, this would work. Thanks!

I'm not actually sure what happens when you have the same key multiple times. Does the JSON parsing fail or does the last value win?

I'm not sure either. We noticed the duplicate key while testing and stopped at that point.

@AlexanderWert AlexanderWert added agent-java community Issues and PRs created by the community labels Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-java community Issues and PRs created by the community
Projects
None yet
Development

No branches or pull requests

3 participants