Skip to content

Commit

Permalink
fix: updated logs in context docs to include a new log enricher for N…
Browse files Browse the repository at this point in the history
…ode.js: Pino
  • Loading branch information
bizob2828 committed Jan 25, 2022
1 parent a24de34 commit 005783d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ APM agent APIs:
* [newrelic_get_linking_metadata](/docs/apm/agents/php-agent/php-agent-api/newrelicgetlinkingmetadata/)

For PHP, logs in context is only supported from the distributed tracing UI, not in the **Logs** tab of the APM UI.

</td>
</tr>
<tr>
Expand Down Expand Up @@ -124,7 +124,7 @@ Also, review the source code for our own logs in context extensions to see how w
* Go: [Logrus extension](https://github.com/newrelic/go-agent/blob/master/_integrations/logcontext/nrlogrusplugin/nrlogrusplugin.go)
* Java: [Log4j2 extension](https://github.com/newrelic/java-log-extensions/blob/master/log4j2/src/main/java/com/newrelic/logging/log4j2/NewRelicLayout.java)
* .NET: [Serilog extension](https://github.com/newrelic/newrelic-logenricher-dotnet/tree/main/src/NewRelic.LogEnrichers.Serilog)
* Node.js: [Winston extension](https://github.com/newrelic/newrelic-winston-logenricher-node/blob/master/lib/createFormatter.js)
* Node.js: [Winston extension](https://github.com/newrelic/newrelic-node-log-extensions/blob/main/packages/winston-log-enricher/lib/createFormatter.js), [Pino extension](https://github.com/newrelic/newrelic-node-log-extensions/blob/main/packages/pino-log-enricher/lib/createFormatter.js)
* PHP: [Monolog extension](https://github.com/newrelic/newrelic-monolog-logenricher-php/blob/master/src/Formatter.php)
* Python: [Streamhandler example](/docs/logs/logs-context/configure-logs-context-python/#python-formatter)
* Ruby: [logging.rb extension](https://github.com/newrelic/newrelic-ruby-agent/blob/dev/lib/new_relic/agent/logging.rb)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ tags:
- Logs
- Enable log management in New Relic
- Logs in context for Node.js
- Winston
- Pino
metaDescription: For apps monitored by the Node.js agent, learn how to link log data with related data across the rest of the New Relic platform.
redirects:
- /docs/logs/new-relic-logs/enable-logs-context/enable-logs-context-nodejs
Expand All @@ -26,8 +28,8 @@ To enable logs in context for APM apps monitored by Node.js:

1. Make sure you have already [set up logging in New Relic](/docs/logs/enable-log-management-new-relic/enable-log-monitoring-new-relic/enable-log-management-new-relic/). This includes configuring a supported log forwarder that collects your application logs and extends the metadata that is forwarded to New Relic.
2. [Install](/docs/agents/nodejs-agent/installation-configuration/update-nodejs-agent/) or [update](/docs/agents/nodejs-agent/installation-configuration/update-nodejs-agent/) to the latest Node.js agent version, and [enable distributed tracing](/docs/distributed-tracing/enable-configure/quick-start/). Use [Node.js agent version 6.2.0 or higher](/docs/release-notes/agent-release-notes/nodejs-release-notes/) for logs in context.
3. Install the [Winston logging framework version 3.0.0 or higher](https://github.com/winstonjs/winston) to enrich your log data.
4. Configure logs in context for Node.js using the Winston extension.
3. Install [Winston 3.0.0 or higher](https://github.com/winstonjs/winston) or [Pino 7.0.0 or higher](https://github.com/pinojs/pino) to enrich your log data.
4. Configure logs in context for Node.js using the appropriate log extension.

<CollapserGroup>
<Collapser
Expand All @@ -49,7 +51,7 @@ To enable logs in context for APM apps monitored by Node.js:
```

The New Relic formatter can be used individually or combined with other formatters as the final format.

```
format: winston.format.combine(
winston.format.label({label: 'test'}),
Expand All @@ -58,6 +60,31 @@ To enable logs in context for APM apps monitored by Node.js:
```
</Collapser>

</CollapserGroup>
<CollapserGroup>
<Collapser
id="nodejs-pino"
title="Node.js configuration with Pino"
>

1. To install the Pino log enricher, enter the following command into your terminal or command line interface:

```
npm install @newrelic/pino-enricher
```
2. In your application code, update your logging configuration to add the New Relic Pino plugin:

```
// index.js
require('newrelic')
const nrPino = require('@newrelic/pino-enricher')
const pino = require('pino')
const logger = pino(nrPino())
```

The New Relic formatter can be used individually or combined with other formatters as the final format.
</Collapser>

</CollapserGroup>

5. To verify that you have configured the log appender correctly, run your application, then check your [logs data in New Relic One](/docs/logs/log-management/ui-data/use-logs-ui/) using the query operator `has:span.id has:trace.id`.
Expand Down

0 comments on commit 005783d

Please sign in to comment.