---
title: Node
description: Collect metrics, traces, and logs from your Node.js applications.
breadcrumbs: Docs > Integrations > Node
---

# Node

## Overview{% #overview %}

The Node.js integration allows you to collect and monitor your Node.js application logs, traces, and custom metrics.

## Setup{% #setup %}

### Metric collection{% #metric-collection %}

The Node.js integration enables you to monitor a custom metric by instrumenting a few lines of code. For instance, you can have a metric that returns the number of page views or the time of any function call.

For additional information about the Node.js integration, see the [guide on submitting metrics](https://docs.datadoghq.com/metrics/custom_metrics/dogstatsd_metrics_submission.md?code-lang=nodejs).

```js
// Require dd-trace
const tracer = require('dd-trace').init();

// Increment a counter
tracer.dogstatsd.increment('page.views');
```

Note that for custom metrics to work you need to enable DogStatsD on the Agent. Collection is enabled by default, but the Agent only listens for metrics from localhost. To allow external metrics, you need to either set an environment variable or update the config file:

```sh
DD_USE_DOGSTATSD=true # default
DD_DOGSTATSD_PORT=8125 # default
DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true # if expecting external metrics
```

```yaml
use_dogstatsd: true # default
dogstatsd_port: 8125 # default
dogstatsd_non_local_traffic: true # if expecting external metrics
```

You'll also need to configure your application to use the agent's DogStatsD collector:

```sh
DD_DOGSTATSD_HOSTNAME=localhost DD_DOGSTATSD_PORT=8125 node app.js
```

### Trace collection{% #trace-collection %}

See the dedicated documentation for [instrumenting your Node.js application](https://docs.datadoghq.com/tracing/setup/nodejs.md) for sending traces to Datadog.

### Log collection{% #log-collection %}

*Available for Agent v6.0+*

See the dedicated documentation to set up [Node.js log collection](https://docs.datadoghq.com/logs/log_collection/nodejs.md) for forwarding your logs to Datadog.

### Profile collection{% #profile-collection %}

See the dedicated documentation for [enabling the Node.js profiler](https://docs.datadoghq.com/profiler/enabling/nodejs.md).

### Code Security{% #code-security %}

See the dedicated documentation for [enabling Code Security for your Node application](https://docs.datadoghq.com/security/code_security.md).

### App & API Protection{% #app--api-protection %}

See the dedicated documentation for [securing your Node.js application](https://docs.datadoghq.com/security/application_security.md) to enable App & API Protection (AAP).

## Data Collected{% #data-collected %}

### Metrics{% #metrics %}

|  |
|  |
| **runtime.node.cpu.user**(gauge)                           | CPU usage in user code*Shown as percent*                                 |
| **runtime.node.cpu.system**(gauge)                         | CPU usage in system code*Shown as percent*                               |
| **runtime.node.cpu.total**(gauge)                          | Total CPU usage*Shown as percent*                                        |
| **runtime.node.mem.rss**(gauge)                            | Resident set size*Shown as byte*                                         |
| **runtime.node.mem.heap\_total**(gauge)                    | Total heap memory*Shown as byte*                                         |
| **runtime.node.mem.heap\_used**(gauge)                     | Heap memory usage*Shown as byte*                                         |
| **runtime.node.mem.total**(gauge)                          | Total system memory size*Shown as byte*                                  |
| **runtime.node.mem.free**(gauge)                           | Free system memory size*Shown as byte*                                   |
| **runtime.node.mem.external**(gauge)                       | External memory*Shown as byte*                                           |
| **runtime.node.heap.total\_heap\_size**(gauge)             | Total heap size*Shown as byte*                                           |
| **runtime.node.heap.total\_heap\_size\_executable**(gauge) | Total executable heap size*Shown as byte*                                |
| **runtime.node.heap.total\_physical\_size**(gauge)         | Total physical heap size*Shown as byte*                                  |
| **runtime.node.heap.used\_heap\_size**(gauge)              | Used heap size*Shown as byte*                                            |
| **runtime.node.heap.heap\_size\_limit**(gauge)             | Heap size limit*Shown as byte*                                           |
| **runtime.node.heap.malloced\_memory**(gauge)              | Malloced memory*Shown as byte*                                           |
| **runtime.node.heap.peak\_malloced\_memory**(gauge)        | Peak allocated memory*Shown as byte*                                     |
| **runtime.node.heap.size.by.space**(gauge)                 | Heap space size*Shown as byte*                                           |
| **runtime.node.heap.used\_size.by.space**(gauge)           | Heap space used size*Shown as byte*                                      |
| **runtime.node.heap.available\_size.by.space**(gauge)      | Heap space available size*Shown as byte*                                 |
| **runtime.node.heap.physical\_size.by.space**(gauge)       | Heap space physical size*Shown as byte*                                  |
| **runtime.node.process.uptime**(gauge)                     | Process uptime*Shown as second*                                          |
| **runtime.node.event\_loop.delay.max**(gauge)              | Maximum event loop delay*Shown as nanosecond*                            |
| **runtime.node.event\_loop.delay.min**(gauge)              | Minimum event loop delay*Shown as nanosecond*                            |
| **runtime.node.event\_loop.delay.avg**(gauge)              | Average event loop delay*Shown as nanosecond*                            |
| **runtime.node.event\_loop.delay.sum**(rate)               | Total event loop delay*Shown as nanosecond*                              |
| **runtime.node.event\_loop.delay.median**(gauge)           | Median event loop delay*Shown as nanosecond*                             |
| **runtime.node.event\_loop.delay.95percentile**(gauge)     | 95th percentile event loop delay*Shown as nanosecond*                    |
| **runtime.node.event\_loop.delay.count**(rate)             | Event loop iteration count where a delay is detected*Shown as execution* |
| **runtime.node.event\_loop.utilization**(gauge)            | Fraction of time the event loop is active*Shown as unit*                 |
| **runtime.node.gc.pause.max**(gauge)                       | Maximum garbage collection pause*Shown as nanosecond*                    |
| **runtime.node.gc.pause.min**(gauge)                       | Minimum garbage collection pause*Shown as nanosecond*                    |
| **runtime.node.gc.pause.avg**(gauge)                       | Average garbage collection pause*Shown as nanosecond*                    |
| **runtime.node.gc.pause.sum**(rate)                        | Total garbage collection pause*Shown as nanosecond*                      |
| **runtime.node.gc.pause.median**(gauge)                    | Median garbage collection pause*Shown as nanosecond*                     |
| **runtime.node.gc.pause.95percentile**(gauge)              | 95th percentile garbage collection pause*Shown as nanosecond*            |
| **runtime.node.gc.pause.count**(rate)                      | Number of garbage collections*Shown as garbage collection*               |
| **runtime.node.gc.pause.by.type.max**(gauge)               | Maximum garbage collection pause by type*Shown as nanosecond*            |
| **runtime.node.gc.pause.by.type.min**(gauge)               | Minimum garbage collection pause by type*Shown as nanosecond*            |
| **runtime.node.gc.pause.by.type.avg**(gauge)               | Average garbage collection pause by type*Shown as nanosecond*            |
| **runtime.node.gc.pause.by.type.sum**(rate)                | Total garbage collection pause by type*Shown as nanosecond*              |
| **runtime.node.gc.pause.by.type.median**(gauge)            | Median garbage collection pause by type*Shown as nanosecond*             |
| **runtime.node.gc.pause.by.type.95percentile**(gauge)      | 95th percentile garbage collection pause by type*Shown as nanosecond*    |
| **runtime.node.gc.pause.by.type.count**(rate)              | Number of garbage collections by type*Shown as garbage collection*       |

## Troubleshooting{% #troubleshooting %}

Need help? Contact [Datadog support](https://docs.datadoghq.com/help/).

## Further Reading{% #further-reading %}

- [How to collect, customize, and centralize Node.js logs](https://www.datadoghq.com/blog/node-logging-best-practices/)
- [Node.js monitoring with Datadog APM and distributed tracing](https://www.datadoghq.com/blog/node-monitoring-apm/)
