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

emitterly

v1.2.0

Published

Create triggers from file streams

Downloads

8

Readme

Emitterly

HitCount Package quality Build Status Coverage Status Licensing Repo size Downloads per week Node version Help us and star this project

A CLI program to listen to file changes in the filesystem and/or internet and execute certain defined actions on a triggered condition Emitterly Uses grok filters to extract key/pair values from new line events to make your payloads more intelligent. This is explained in detail below.

Installation

npm install emitterly --global

Usage

Type emitterly or emitterly -c "path/to/settings.yml" to run the tool.

Emitterly will try to load a settings.yml file in the folder you executed the command in

You can run emitterly with DEBUG=emitterly:* emitterly to view debug messages

Command-Line Arguments

| Argument | Explanation | Default | | ---------------- | --------------------------------------------------------- | ---------------- | | -h | Shows help | | | -c <file> | Specifies the file path to the settings.yml | ./settings.yml | | -e <encoding> | Sets the encoding of event files | utf-8 | | -s <separator> | Sets the line separator token | /[\r]{0,1}\n/ | | -u | Runs eval for conditions and actions instead of safe-eval | false | | -b | Reads event files from the beginning | false | | -f | Forces flush of data when EOF is reached. | false | | -p | Prints pretty errors when thrown | false |

Settings

events:
  newlineevent: # This is a event name, you can have multiple events
    file: './test.txt' # The file to watch, you can also use URL's

    # You can have multiple filters
    filters: # Filters are GROK patterns
      # this filter called filter1 will match for example: [12:08:44] 192.168.2.1 (INFO) - User logged in
      filter1: '\[%{TIME:time}\] %{IP:ip} \(%{WORD:type}\) - %{GREEDYDATA:message}'

    # There can be multiple actions
    actions:
      # A webhook action only needs a url to post to, it will post in JSON format
      webhook: 'https://webhook.site/04ed7a87-f9e5-472d-8f66-fc50f83b0a67'

      # Executes a command, can be virtually anything
      exec: 'node ./trigger.js'

      # You can eval javascript, this is by default safe-eval instead of eval
      eval: 'console.log("This is a console log from a action trigger")'

    # The condition for the actions to be triggered in this event, you can use variables from the event class itself
    # For example: '"%match.ip%" == "192.168.2.1"'
    condition: '1 === 1'

    # The payload to send with the actions, this currently only works for the webhook action
    payload:
      ip: '%match.ip%'
      data: 'Emitterly sent a payload! event: %event% condition = %condition% here is a customstring'

Grok

grok is a way to match a line against a regular expression and map specific parts of the line into dedicated fields.

For example consider the following new added line to a file that you are monitoring with Emitterly:

[12:08:44] 192.168.2.1 (INFO) - User logged in

You could transform this information to a payload object within Emitterly by specifying a grok match pattern in your settings.yml file inside the filters of a event:

filters:
  filter1: '\[%{TIME:time}\] %{IP:ip} \(%{WORD:type}\) - %{GREEDYDATA:message}'

Which will result in the following object:

{
    time: '12:08:44',
    ip: '192.168.2.1',
    type: 'INFO',
    message: 'User logged in'
}

You can then use this to send as a payload or to use it in your condition line in settings.yml

condition: '"%match.ip%" == "192.168.2.1"'

So now your payload will only be sent to your action if this condition matches

License

Copyright (c) 2019 by GiveMeAllYourCats. Some rights reserved. Emitterly is licensed under the MIT License as stated in the LICENSE file.