I use logstash-plugin to send console logs to a server Graylog.
The jenkins job is a declarative pipeline with several stages that runs in parallel on different kind of agent (See attached example).
I expected to find in Graylog, for each line of the console logs, the environment variables of the stage that is running with at least the environment variables such as STAGE_NAME and NODE_NAME that would help to extract logs for a dedicated stage.
But I found in Graylog environment variables of the parent build and therefore I don't find the STAGE_NAME and the NODE_NAME.
As the stage might run in parallel, the logs of each stages are mixed and it is impossible to setup some graylog filters to watch a dedicated stage.
I would like to have the NODE_NAme to discover some correlation between errors that might be seen in the log and the agent that was running the stage.
I dig inside the code and found in BuildData.java that it was the build.getEnvironment(listener) that recovers the environment variables of the parent build.
If I want to make some evolution of the plugin, what advise would you give to recover the environment parameters of the stage instead of the parent build in BuildData.java?
I did not found any solution via the variable "build".
Thanks by advance for any help.