@jermeo/winston-datadog
v1.0.1
Published
Secure TCP transport for Winston and Datadog
Downloads
2
Maintainers
Readme
Winston Datadog TCP secure
- Use with Winston 3+
- Typescript support
- Initially forked from winston-tcp
Install
npm i @jermeo/winston-datadog
API
Typescript
import * as logger from "winston";
import DatadogTcpTransport from "@jermeo/winston-datadog";
const {combine, timestamp } = logger.format;
logger.configure({
level: 'info',
format: combine(
timestamp()
),
transports: [
new DatadogTcpTransport({
level: 'info',
host: 'intake.logs.datadoghq.com',
port: 10516,
apiKey : 'DATADOG_API_KEY',
tags: {
app: 'my-service',
env: 'dev'
}
})
]
});
const greeting = (person: string) => {
logger.info('Good day ' + person, {service: 'my-service'});
};
greeting('Daniel')
js
const { createLogger, transports } = require('winston');
const winstonTcpDatadog = require('@jermeo/winston-datadog');
const options = {
console: {
level: 'debug',
handleExceptions: true,
json: true
},
datadogOptions: {
level: 'info',
host: 'datadog_secure_tcp_endpoint',
port: datadog_secure_tcp_port,
apiKey : 'DATADOG_API_KEY',
tags: {
app: 'my-service',
env: 'dev'
}
}
};
const logger = new createLogger({
transports: [
new transports.Console(options.console),
new winstonTcpDatadog(options.datadogOptions)
],
exitOnError: false, // do not exit on handled exceptions
});
// logs needs to be in json
logger.info('message', {service: "service-name", ...})
Options
Name | Description | Default
------------------- | ----------------------------------------------------------------------------- | -------
host
| The host to connect to | none
port
| The server port to connect to | none
apiKey
| Your datadog API Key | none
reconnectInterval
| Time to pause between disconnect and reconnect (in ms) | 1000
bufferLength
| Number of messages to buffer while disconnected, set to false
for unlimited | 10000
tags
| Tags to send to Datadog | none
License: ISC ·