npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslogger

v0.1.9

Published

Elasticsearch js client wrapper with daily indexes (ala logstash) using buffers and bulk inserts for efficiency

Downloads

3

Readme

npm version

Logging, esse

This is a light wrapper for sending data to Elasticsearch in a predictable manner. It uses the Elasticsearch JS Client and accepts all the same arguments for configuration

Main features:

  • Daily log indexes using a logstash-style naming with your supplied prefix
  • Map Index creation and update capabilites (to make sure your data gets digested the way you like)
  • Buffering and Bulk Insert by default, to decouple log load from ES connections.
  • fine-grained filtering for particular object types, e.g. http request objects (built in)
  • user-defined filtering - create a function that returns an object, and it will be matched to incoming arguments

Installation

npm install eslogger --save

Example Usage

Put this in a script, and edit the hosts array to point at a legit Elasticsearch destination, then run it. It will start a webserver that you can browse to at 127.0.0.1:1337. Each time you visit that page, you'll be creating a "hit" document. Note the following:

  • Set dryrun:false if you want to actually send data out.
  • filters:[null,'req'] defines how the arguments are handled when calling esl.log('hit',{foo:'bar'},req);
    • null means no filtering,
    • 'req' means use the built-in request object filter (currently the only built-in filter)
    • supply your own filter function(s), e.g. function(ob){ return {quux:ob.quux}; }

var prefix = "thefoobar"
var settings = {
    dryrun  : true,
    verbose : true,
    prefix  : prefix,
    filters : [null,'req'],
    hosts   : [
        { host: 'es-server-1.my-es-cluster.com',port: 9200},
        { host: 'es-server-2.my-es-cluster.com',port: 9200}
    ],
    mapping : {
        "template" : prefix + "-*",
        "order": 0,
        "settings": {},
        "mappings": {
            "hit" : {
                "properties":{
                    "id"              : {"index": "not_analyzed", "type": "string"},
                    "domain_name"     : {"index": "not_analyzed", "type": "string"},
                    "browser"         : {"index": "not_analyzed", "type": "string"},
                    "http_referer"    : {"index": "not_analyzed", "type": "string", "ignore_above": 512},
                    "http_user_agent" : {"index": "not_analyzed", "type": "string", "ignore_above": 256},
                    "ip_address"      : {"index": "not_analyzed", "type": "string"},
                    "server"          : {"index": "not_analyzed", "type": "string"},
                    "querystring"     : {"index": "not_analyzed", "type": "string", "ignore_above": 256},
                    "os.family"       : {"index": "not_analyzed", "type": "string"},
                }
            },
        },
        "aliases": {}
    }
};
var esl = require('eslogger').ESLogger(settings);
esl.mapping();

// set up an example web service to do some logging
var http = require('http');
http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World\n');


    esl.log('hit',{foo:'bar'},req);


}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');