> ## Documentation Index
> Fetch the complete documentation index at: https://docs.germainux.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Node.js Network Monitoring

> Monitor incoming and outgoing HTTP traffic in Node.js applications, and control it through GermainAPMConfiguration.

Components
[`Code Profiler`](https://docs.germainux.com/main/germain-ux-code-profiler)

Availability
8.6.0 or later

> [card] [Incoming HTTP Monitoring](#incoming-http-monitoring)
>
> Turning off inbound tracking

> [card] [Outgoing HTTP Monitoring](#outgoing-http-monitoring)
>
> Disabling outbound request tracking

## Incoming HTTP Monitoring

By default GermainUX monitors incoming http traffic. You can disable this monitoring through `GermainAPMConfiguration`:

```javascript theme={null}
const config = GermainAPM.getDefaultConfiguration('http://GERMAIN_APM_SERVER/');
config.monitoring.httpIncoming.enabled = false;
```

### Session extraction

In addition you can provide a session extractor function to extract session ids from the incoming http traffic. By default, no session extractor is provided.

Example below shows how you can extract an existing session id from incoming http requests' headers and pass it on to the GermainUX monitoring :

```javascript theme={null}
const config = GermainAPM.getDefaultConfiguration('http://GERMAIN_APM_SERVER/');
config.monitoring.httpIncoming.sessionExtractor = function(incomingMessage) { // you receive an instance of the <http.incomingMessage>
  return incomingMessage.headers.sessionId;
};
```

### GermainUX with Incoming HTTP

GermainUX allows you to tag UX monitoring data and correlate it with incoming http traffic in Node.js. To allow this correlation make sure UX is configured to tag data and Node.js is configured to allow custom http headers.

GermainUX configuration (taggingEnabled flag must be set to true):

```javascript theme={null}
const settings = germainApm.getDefaultSettings(loaderArgs, agentConfig);
settings.plugins.network.trackingEnabled = true;
```

Node.js configuration to allow `germain-apm-sequence` custom http header:

```javascript theme={null}
app.use(function(req, res, next) {
  	res.header("Access-Control-Allow-Origin", "*");
  	res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, germain-apm-sequence");
  	next();
});
```

## Outgoing HTTP Monitoring

By default GermainUX monitors outgoing http traffic. You can disable this monitoring through `GermainAPMConfiguration`:

```javascript theme={null}
const config = GermainAPM.getDefaultConfiguration('http://GERMAIN_APM_SERVER/');
config.monitoring.httpOutgoing.enabled = false;
```

### Session extraction

In addition you can provide a session extractor function to extract session ids from the outgoing http traffic. By default, no session extractor is provided.

Example below shows how you can extract an existing session id from outgoing http requests' headers and pass it on to the GermainUX monitoring :

```javascript theme={null}
const config = GermainAPM.getDefaultConfiguration('http://GERMAIN_APM_SERVER/');
config.monitoring.httpOutgoing.sessionExtractor = function(clientRequest) { // you receive an instance of the <http.clientRequest>
  return clientRequest.getHeader('sessionId');
};
```

## Get Help

> [card] [Contact GermainUX Support](https://docs.germainux.com/main/support.md)
>
> The GermainUX team helps you get up and running faster, empower your team, turn data into actionable insights, and optimize performance to deliver measurable business outcomes.

> [card] Can't find what you need?
>
> Search all GermainUX docs with **Ctrl + K**, or use the feedback buttons at the bottom of this page to tell us what is missing.

The content of this document is proprietary to GERMAIN SOFTWARE.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.