Nicely Presented Misnomer

    @jermeo/winston-datadog
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.1 • Public • Published

    Winston Datadog TCP secure

    npm JavaScript Standard Style

    TCP transport for Datadog with Winston

    npm

    • 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  · 

    Install

    npm i @jermeo/winston-datadog

    DownloadsWeekly Downloads

    2

    Version

    1.0.1

    License

    ISC

    Unpacked Size

    10.5 kB

    Total Files

    6

    Last publish

    Collaborators

    • jermeo