diff --git a/other-examples/java/logs-in-context-log4j2/.env b/other-examples/java/logs-in-context-log4j2/.env new file mode 100644 index 00000000..3345296d --- /dev/null +++ b/other-examples/java/logs-in-context-log4j2/.env @@ -0,0 +1,2 @@ +NEW_RELIC_OTLP_ENDPOINT=https://otlp.nr-data.net:4317 +NEW_RELIC_API_KEY= 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: