newrelic / newrelic-java-agent

The New Relic Java agent
Apache License 2.0
202 stars 144 forks source link

Attach custom attributes to Log events via the Java agent config #2037

Open kford-newrelic opened 2 months ago

kford-newrelic commented 2 months ago

Is your feature request related to a problem? Please describe.

Customer switched from using Logstash to forward logs to New Relic, to using our Java agent to do the same thing.

Feature Description

In their Logstash config, they were able to tag on custom attributes to their log events, using the following format:

input {
  file {
    path => "/var/log/supervisor/java-*.log"
    add_field => {
      custom_field => "custom_value"
    }
start_position => "beginning"

codec => json {
    }
  }
}

They would like to see us implement a similar feature in the Java agent config, not unlike our current Labels solution but specific to Log events. A simple list of key / value pairs that would be attached to every log event sent up by that Java agent.

Describe Alternatives

N/A

Additional context

Before starting any initial spiking, we should try to engage the requesting customer (through their account team), to see if they'd be willing to guide feature development and later try snapshot agent versions.

Review epic description on NR-315883

Similar Jiras on this topic - NR-303269, NR-310852 & NR-312135

Priority

Please help us better understand this feature request by choosing a priority from the following options: [Nice to Have]

workato-integration[bot] commented 2 months ago

https://new-relic.atlassian.net/browse/NR-261047

jasonjkeller commented 1 month ago

The Java agent supports adding custom attributes to log events via MDC. https://docs.newrelic.com/docs/apm/agents/java-agent/configuration/java-agent-configuration-config-file/#log-context-data

There are also ongoing discussions between agent and logging teams about adding tags/labels to log events as attributes, which could function as global attributes on all log events.