Giter Club home page Giter Club logo

stdout-mq's Introduction

stdout-mq

Build Status

Pino-mq will take all messages received on process.stdin and send them over a message bus using JSON serialization;

Installation

npm install -g stdout-mq

Quick Example

Bash pipes:

node app.js 2>&1 | stdout-mq -u "amqp://guest:guest@localhost/" -q "pino-logs"

Via sub-process, optimized for use with Docker:

stdout-mq -u "amqp://guest:guest@localhost/" -q "pino-logs" --spawnProcess="node app.js"

Command line switches

  • --type (-t): MQ type of transport to be used (default 'RABBITMQ')
  • --uri (-u): uri for connecting to MQ broker
  • --queue (-q): queue to be used for sending messages
  • --fields (-f): comma separated fields for filtering messages before sending
  • --exchange (-e): exchange name to be used in case of rabbitmq transport
  • --config (-c): path to config file (JSON); switches take precedence
  • --generateConfig (-g): create pino-mq.json config file with default options
  • --help (-h): display help
  • --version (-v): display version
  • --wrapWith (-ww): wrap a message with custom data where %DATA% will be replaced with a message e.g. {"data": "%DATA%", "customProp": "customData"}
  • --spawnProcess (-sp): Spawns a sub-process using specified command & listens it's stdout/stderr

Configuration JSON File

by using --generateConfig it will create pino-mq.json file with all available configuration options;

{
 "type": "RABBITMQ",
 "uri": "amqp://guest:guest@localhost/",
 "exchange": "",
 "queue": "stdout-mq",
 "fields": []
}

Broker connection

  • uri option will follow URI specification for defining connection to a host:

    <protocol>://[user[:password]@]host[:port][/path][?query]
    

    where protocol, path and fragment will be specific for each type of broker

Configuration via environment variables

You may specify MQ_PROTOCOL, MQ_LOGIN, MQ_PASSWORD, MQ_HOST as env variables, these variables are going to be used to create URI for connecting to MQ broker, in this way, you can avoid using --uri (-u) param in CLI

Queues configuration

queue configuration has a priority in defining behaviour for stdout-mq; if more than one is specified, configuration will take this precedence:

  1. queue all messages will be sent on this queue

RabbitMQ specific options

For RabbitMQ type there is an extra option:

  • --exchange: if you want to use a specific exchange for your queues or you want to use topics instead of queues than you have to pass it to pino-mq configuration; topics are a more powerful distribution mechanism than queues and explaining it is beyond the scope of this module (RabbitMQ Topics tutorial)

Fields filtering

in case is needed to filter log messages fields you can use fields option:

  • from command line:
    • --fields "time,level,msg"
  • from configuration json file:
    • "fields":["time","level","msg"]

LICENSE

Apache-2.0 License

stdout-mq's People

Contributors

dependabot[bot] avatar itavy avatar oleh-momot avatar stylet avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

hotnix87

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.