New Relic Java APM agent: Determining effective app_name when both newrelic.yml and environment variable are set
0 reputation · 28 May 2020, 20:08 UTC
0 reputation · 28 May 2020, 20:08 UTC
Goal: guarantee that a single deployable image produces the same New Relic APM entity name regardless of the environment it runs in.
Uncertainty: when both newrelic.yml defines app_name and the NEW_RELIC_APP_NAME environment variable (or JVM system property) are present, the agent’s precedence rules determine which value wins, and those rules can differ across agent releases, potentially splitting one service into multiple entities. Additionally, an incorrect region/endpoint paired with a valid license key may silently drop data, complicating validation.
Questions:
app_name when both the YAML file and the environment variable are set?app_name and ingest region produce expected telemetry without altering the immutable artifact?35775 reputation · 28 May 2020, 20:32 UTC
For current New Relic Java agent generations, the NEW_RELIC_APP_NAME environment variable (or the equivalent JVM system property) takes precedence over the app_name value in newrelic.yml. The environment variable wins. This precedence is version-sensitive, however: some older major agent releases may ignore the environment variable for app_name and require the JVM system property instead.
Confirmed: The agent resolves the effective application name at startup. That resolved value is reported in the agent startup logs and reflected in the New Relic UI under the entity’s configuration details. A valid license key paired with an incorrect ingest region or endpoint can cause telemetry to be dropped silently, so region validation is as important as name validation.
Assumption requiring verification: The environment-variable-over-YAML precedence described above is the expected behavior for modern agent releases. Because the question involves a pinned, immutable artifact, the exact major version of the Java agent inside that image determines whether the environment variable is sufficient or whether the JVM system property must also be supplied.
Because the deployable image is immutable, apply overrides at runtime and inspect the result:
NEW_RELIC_APP_NAME=my-service
# set the region/endpoint variable documented for your agent version
java -jar app.jar
-Dnewrelic.app_name=my-service
app_name and the ingest endpoint being used.The exact major version of the New Relic Java agent in the image. If it is a current major generation, the environment variable alone is the standard override. If it is a legacy major version, the environment variable may be ignored for app_name, and the JVM system property becomes the reliable mechanism. Until that version is confirmed, the conservative approach is to set both the environment variable and the JVM system property to the same value.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.