I'm using the EDOT Java agent, which automatically generates and exports logs/metrics/tracing from my Java application to Elastic. However, I'm having a hard time enriching the log documents.
The goal is to be able to query the index with some sort of id to retrieve all logs related to a task.
I have tried to get MDC attributes to be exported with the logs, but that does not seem to work with the EDOT SDK.
Anyone have any idea how this would usually be done?
Pseudo example of concept:
while (true) {
// main program loop
Task task = getNextTask();
Logger.current().setAttribute("task.id", task.id);
task.run();
}
If I then want all logs related a task, I would just query my index with the task.id.
The only solution I have found so far is (Pseudo) :
while (true) {
// main program loop
Task task = getNextTask();
Span.current().setAttribute("task.id", task.id);
task.run();
}
First query the trace index with with a task.id to fetch the trace.id, and then use the trace.id on the log index to get all log documents related to my task.