NodeJS

Configure NodeJS Log Source with observIQ

Supported Versions

NodeJS versions

  • v16
  • v15
  • v14
  • v13
  • v12

Supported Platforms

Source

Windows

Linux

Mac

Kubernetes

Openshift

NodeJS

Prerequisites

Configure the Winston logging library and use json. For more information, see the Winston docs here.
Here's an example using Express:

    transports: [
        new winston.transports.Console()
    ],
    format: winston.format.combine(
        winston.format.json()
    )
}
const logger = new winston.createLogger(winstonOptions)
const requestLogger = expressWinston.logger(winstonOptions)
const errorLogger = expressWinston.errorLogger(winstonOptions)

Configuration

Option

Description

Log source

Use this field to specify where your logs are coming from. When choosing the 'file' option, the agent reads in logs from the log paths specified below. When choosing the 'Kubernetes' options, the agent reads logs from /var/log/containers based on the Pod and Container specified below.

File Path (file)

Specify a single path or multiple paths to read one or many files. You may also use a wildcard (*) to read multiple files within a directory.

Exclude File Path (file)

Specify a single path or multiple paths to exclude one or many files from being read. You may also use a wildcard (*) to exclude multiple files from being read within a directory.

Encoding (file)

Specify the encoding of the file(s) being read. In most cases, you can leave the default option selected.

Cluster Name (kubernetes)

Cluster Name to be added to a resource label.

Pod Name (kubernetes)

The pod name (without the unique identifier on the end).

Container Name (kubernetes)

The container name.

Start At

Choose whether to start reading from the beginning or end of a file with "end" being the default.

Log Types

Types

nodejs

Dashboards

Users can configure dashboards using visualizations. More information can be found on our visualizations and dashboards page.

Advanced

For more information on the advanced configuration capabilities, see our detailed plugin guide here.