Skip to content

Latest commit

 

History

History

legacy-logs-in-context

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Deprecation notice

This example should be considered to be deprecated. Instead of following this method of delivering logs, we recommend that customers use the Node agent for logs in context and log forwarding.

New Relic Node.js logs in context Example

This project demonstrates logs in context with New Relic by using a Node.js application and log enrichers.

The sample application has support for the two log enrichers: @newrelic/winston-enricher and @newrelic/pino-enricher. It also contains a container to run fluentd with the fluent-plugin-newrelic to forward logs to New Relic One.

Getting Started

Note: You must have Docker and Docker Compose installed. The steps below are using hey to generate load on the sample app.

  1. Clone or fork this repository.

  2. Copy .env.example to .env and fill out the following keys:

    NEW_RELIC_LICENSE_KEY=<New Relic License Key>
    # By default the app is using pino + @newrelic/pino-enricher
    # If you want to use winston + @newrelic/winston-enricher add
    # WINSTON=1
  3. Build containers docker-compose build

  4. Start containers docker-compose up -d

  5. Make requests to the app

    hey -z 5m http://localhost:3000
  6. Navigate to New Relic One > APM > (select an app) > Triage > Logs. logs in context landing

  7. Click a log line in the list view. log list with details

  8. View the details of the log entry and you can see entity.*, span.id and trace.id metadata added. log details

  9. Navigate to APM > (select an app) > Monitor > Distributed Trace. Click a trace group > trace > See logs(top right of pane). distributed tracing

  10. You can now see all relevant logs for a given trace. logs for trace

Additional Configuration

If you are a New Relic employee and wanting to testing on a staging environment, add the following:

NEW_RELIC_HOST=staging-collector.newrelic.com
NEW_RELIC_LOG_HOST=https://staging-log-api.newrelic.com/log/v1