<commit_before>simple-udp-stream
=================

[![Build status](https://travis-ci.org/ddm/simple-udp-stream.svg)](https://travis-ci.org/ddm/simple-udp-stream)
[![Dependency Status](https://david-dm.org/ddm/simple-udp-stream.svg)](https://david-dm.org/ddm/simple-udp-stream)

## Basic usage

    var SimpleUdpStream = require('simple-udp-stream');

    var stream = new SimpleUdpStream({
      destination: '127.0.0.1',
      port: 9999
    });

    stream.write("Hello World!");

![Wireshark capture](https://i.imgur.com/89Am8Zu.png)

## Bunyan and logstash

Configure [logstash](http://logstash.net/) to listen to UDP logs:

    input {
      udp {
         port => 9999
         codec => json
      }
    }
    output {
      elasticsearch {
        host => localhost
        protocol => http
      }
    }

Configure [bunyan](https://github.com/trentm/node-bunyan) to log over UDP:

    var bunyan = require('bunyan');

    var logger = bunyan.createLogger({
      name: 'my-logger',
      streams: [{
        level: 'info',
        stream: require('simple-udp-stream')({
          destination: '127.0.0.1',
          port: 9999
        })
      }]
    });

    logger.info({ value: 1 }, "Hello World!");<commit_msg>More screenshots<commit_after>simple-udp-stream
=================

[![Build status](https://travis-ci.org/ddm/simple-udp-stream.svg)](https://travis-ci.org/ddm/simple-udp-stream)
[![Dependency Status](https://david-dm.org/ddm/simple-udp-stream.svg)](https://david-dm.org/ddm/simple-udp-stream)

## Basic usage

    var SimpleUdpStream = require('simple-udp-stream');

    var stream = new SimpleUdpStream({
      destination: '127.0.0.1',
      port: 9999
    });

    stream.write("Hello World!");

![Wireshark simple capture](https://i.imgur.com/89Am8Zu.png)

## Bunyan and logstash

Configure [logstash](http://logstash.net/) to listen to UDP logs:

    input {
      udp {
         port => 9999
         codec => json
      }
    }
    output {
      elasticsearch {
        host => localhost
        protocol => http
      }
    }

Configure [bunyan](https://github.com/trentm/node-bunyan) to log over UDP:

    var bunyan = require('bunyan');

    var logger = bunyan.createLogger({
      name: 'my-logger',
      streams: [{
        level: 'info',
        stream: require('simple-udp-stream')({
          destination: '127.0.0.1',
          port: 9999
        })
      }]
    });

    logger.info({ value: 1 }, "Hello World!");

![Kibana capture](https://i.imgur.com/u2yuKv6.png)

![Wireshark bunyan capture](https://i.imgur.com/ulxG3Kz.png)
{'fraction_non_alphanumeric': 0.17884914463452567, 'fraction_numerical': 0.022939346811819597, 'mean_word_length': 2.5150273224043715, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '842636', 'n_tokens_mistral': 946, 'n_tokens_neox': 888, 'n_words': 150}