bpaquet / node-logstash

Simple logstash implmentation in nodejs : file log collection, sent with zeromq
Other
517 stars 141 forks source link

node-logstash

Build Status

What is it ?

It's a NodeJS implementation of Logstash.

What to do with node-logstash ?

node-logstash is a tool to collect logs on servers. It allows sending its logs to a central server and to ElasticSearch for indexing.

On top of the elastic search, you can use a specialized interface like kibana to dive into your logs.

Archi

Why a new implementation?

When I tried logstash, I had some problems. This project mainly addresses those problems. This version should have:

Moreover, it's written in NodeJS, which is a perfect language for programs with many IO.

node-logstash is compatible with logstash. You can replace a node-logstash node with a logstash one. The data are formatted in the same way to be compatible with logstash UIs.

How does it work?

The architecture is identical to logstash architecture. You have to instantiate plugins with the node-logstash core. There are three type of modules:

A typical node-logstash deployment contains agents to crawl logs and a log server.

On agent, node-logstash is configured with inputs plugins to get logs from your software stack, and one output plugin to send logs to log server (eg. zeromq output plugin).

On log server, logs come through a zeromq input plugin, are processed (fields and timestamps extraction), and send to ElasticSearch.

How to get help?

Please open an issue.

Future of this project

October 25th, 2015.

When I started node-logstash, the ecosystem around logstash and ElasticSearch were almost non-existent. In 2015, the situation is not the same :

So, what is the future of node-logstash?

Current project status

Node-logstash is production ready and used in production. Installation is a classical node project installation, with some scripts for native packaging.

Maintainers: currently I, @bpaquet, am the only maintainer. I will keep dependencies up to date, update the core to follow node version, but I do not have time to add features to the core. See Contributing below.

Weaknesses :

Contributing

Which Pull Requests (PR) will be merged?

Add plugin (output, input or filter)

Conditions to have a PR merged :

You are encouraged to ask to merge plugins without tests, which are not production ready.

Core modification

Please respect jslint, and provide all needed unit tests. How to use it?

Installation

Simple way

Use prepackaged deb files.

After install, just add your config files to /etc/node-logstash/plugins.conf.d, and restart node-logstash service node-logstash restart.

To see what options are passed to node-logstash, see here.

To change log level, do node-logstash config:set LOG_LEVEL=debug, and restart node-logstash.

Manual install

The executable is bin/node-logstash-agent

Configuration formats

There are two formats for configuration:

  1. The legacy format uses URLs.
  2. The other one is identical to the logstash config format.

Note: if you are using multiple config files, you can mix formats.

Configuration by URL (legacy)

A plugin is instantiated by an URL. Example: input://file:///tmp/toto.log. This URL instantiates an input file plugin which monitors the file /tmp/toto.log.

The URLs can be specified:

Configuration by logstash config files (recommended)

Example for an input file

input {
  file {
    path => '/tmp/toto.log'
  }
}

You can use if to have an event dependent configuration. See here for details. As for URLs, config can be specified

Note: the implementation is young, all bugs reports are welcome. Note: both formats can be mixed.

Command lines params

Examples

Config file for an agent:

input {
  file {
    path => "/var/log/nginx/access.log"
  }
}

output {
  zeromq {
    address => ["tcp://log_server:5555"]
  }
}

Config file for log server:

input {
  zeromq {
    address => ["tcp://0.0.0.0:5555"]
  }
}

filter {
  regex {
    pattern => http_combined
  }
}

output {
  elasticsearch {
    host => localhost
    port => 9200
  }
}

Adding your plugins

You can add easily add your plugins :

Manually :

With native packaging

The plugins must be deployed in /var/db/node-logstash/custom_plugins. All subdirectories already exist. The NODE_PATH is already set.

Signals

Changelog

Changelog

Plugins list

Input plugins

Common concepts / parameters :

Filter plugins

Common concepts / parameters :

Outputs

Common concepts / parameters :

Misc

License

Copyright 2012 - 2014 Bertrand Paquet

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.