From ee0f9bf0cee56433d56daf08c847e777503c3f89 Mon Sep 17 00:00:00 2001 From: Alan West <3676547+alanwest@users.noreply.github.com> Date: Wed, 4 Oct 2023 11:15:08 -0700 Subject: [PATCH] Make log4j example easier to run (#455) --- other-examples/java/logs-in-context-log4j2/README.md | 8 ++------ .../java/logs-in-context-log4j2/docker-compose.yaml | 2 ++ .../java/logs-in-context-log4j2/otel-config.yaml | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/other-examples/java/logs-in-context-log4j2/README.md b/other-examples/java/logs-in-context-log4j2/README.md index 74befe44..d7997f76 100644 --- a/other-examples/java/logs-in-context-log4j2/README.md +++ b/other-examples/java/logs-in-context-log4j2/README.md @@ -36,15 +36,11 @@ The following image illustrates a similar example using FluentBit: Next, build and run the application: ```shell -// Build the application -docker compose build -./gradlew logs-in-context-log4j2:bootJar - // Export your New Relic API key as an environment variable export NEW_RELIC_API_KEY= -// Run the application and the collector with docker compose -docker compose up +// Build and run the application +docker compose up --build ``` Navigate to the app in a browser at `http://localhost:8080`. diff --git a/other-examples/java/logs-in-context-log4j2/docker-compose.yaml b/other-examples/java/logs-in-context-log4j2/docker-compose.yaml index 3de5bc3e..c453cb44 100644 --- a/other-examples/java/logs-in-context-log4j2/docker-compose.yaml +++ b/other-examples/java/logs-in-context-log4j2/docker-compose.yaml @@ -7,6 +7,7 @@ services: # Logs are forwarded to collector using fluentd OTEL_LOGS_EXPORTER: none OTEL_EXPORTER_OTLP_ENDPOINT: 'http://collector:4317' + OTEL_EXPERIMENTAL_RESOURCE_DISABLED_KEYS: 'process.command_line,process.command_args' ports: - '8080:8080' logging: @@ -23,6 +24,7 @@ services: command: ["--config=/otel-config.yaml"] environment: LOG_EXPORTER_LOG_VERBOSITY: "detailed" + NEW_RELIC_OTLP_ENDPOINT: ${NEW_RELIC_OTLP_ENDPOINT} NEW_RELIC_API_KEY: '${NEW_RELIC_API_KEY}' ports: - '4317:4317' # OTLP gRPC receiver diff --git a/other-examples/java/logs-in-context-log4j2/otel-config.yaml b/other-examples/java/logs-in-context-log4j2/otel-config.yaml index 05ada36e..463576f1 100644 --- a/other-examples/java/logs-in-context-log4j2/otel-config.yaml +++ b/other-examples/java/logs-in-context-log4j2/otel-config.yaml @@ -24,7 +24,7 @@ exporters: logging: verbosity: $LOG_EXPORTER_LOG_VERBOSITY otlp: - endpoint: https://otlp.nr-data.net:4317 + endpoint: $NEW_RELIC_OTLP_ENDPOINT headers: "api-key": $NEW_RELIC_API_KEY service: