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

bunyan-elasticsearch-stream

v1.5.0

Published

A Bunyan stream for sending logs to Elasticsearch or Elastic Cloud data stream

Downloads

43

Readme

bunyan-elasticsearch-stream

  • A Bunyan stream for saving logs into Elasticsearch.
  • Buffers logs in memory instead of sending them to the Elasticsearch server one by one.
  • The logs are accumulated in memory until a certain number of logs reached or a certain amount of time passed without sending any logs.
  • The goal is to save resources on both your application and Elastic Search server (ex: lowering costs in AWS).
  • Written in Typescript.

Based on bunyan-elasticsearch-bulk

Requirements

Installation

npm i bunyan-elasticsearch-stream

Usage with Node

import bunyan from "bunyan";
import { BunyanESStream } from "bunyan-elasticsearch-stream";

const config = {
  name: 'Application Name',
  streams: [{
    level: 'debug',
    stream: new BunyanESStream({
      clientOptions: { node: "http://localhost:9200" },
    })
  }]
}

const log = bunyan.createLogger(config)

// From here, you can log things according to the best practices of Bunyan.
// Please familiarize yourself with it here: https://github.com/trentm/node-bunyan

log.info('Log this message!')
log.info({ otherInfo: 'What else do you need to log here?' }, 'Log this message!')

List of Configuration Parameters

| Field | Default | Description | | ------------- | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | | indexName | app-log | Index name for the Elasticsearch data stream | | limit | 100 | How many logs to collect before submitting them to ES | | interval | 5000 | Time in milliseconds before submitting logs even if their count has not reached the limit | | clientOptions | {} | Elasticsearch client options | | client | Client(options.clientOptions) | If you don't want to use the included version of the client v7.x, you can configure the one you want and pass it here |

Emitted Events

Check server.ts for example usages:

| Event | Fires when .. | | --------------- | ---------------------------------------------------------------------------------------- | | log_received | we receive a log | | log_submitted | we bulk-submit logs to ES server. With a reason limit_exceeded or timeout | | error | an error happens in the whole bulk submission or when saving an individual message fails |

License

MIT