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

node-moog

v1.2.9

Published

Publish events to the MOOG AIOps REST LAM

Downloads

21

Readme

Moogsoft Logo

Moogsoft AIOps REST Client for Node.js

NPM Code Climate

NPM

Allows connecting to the Moogsoft AIOps REST LAM and sending events to be used by the algorithmic processing functions of the product.

  • Provides a formatted event object with reasonable defaults
  • Provides for passing the shared secret
  • Provides specific port designation

Installation

$ npm install node-moog

Usage

Simple Event Generation

Populate a pre configured event object MoogEvent(mEvent)

mEvent is an optional default event template, if none is supplied then reasonable defaults are used for many fields

var MoogEvent = require('node-moog').MoogEvent;

myEvent = new MoogEvent();

myEvent.description = 'My new description';

Elements available in an event.

  • myEvent.signature //String
  • myEvent.source_id //String
  • myEvent.external_id //String
  • myEvent.manager //String
  • myEvent.source //String
  • myEvent.class //String
  • myEvent.agent_location //String
  • myEvent.type //String
  • myEvent.severity //Int
  • myEvent.description //String
  • myEvent.first_occurred // Epoch Int
  • myEvent.agent_time // Epoch Int

Create a connection

Create a connection to the REST LAM moogREST(options)

options is an object containing connection specific settings


var moogRest = require('node-moog').moogREST({'url':'http://hostname:8888','auth_token':'my_secret'});

auth_token is optional and depends on the REST LAM configuration.


var moogRest = require('node-moog').moogREST({'url':'http://hostname:8888','authUser':'graze','authPass':'xxxxx'});

authUser and authPass are for basic auth and depend on the REST LAM configuration, it is strongly advised to use basic auth with tls, requires version 5.0.7+ of moog REST LAM.

To use tls (https)

To pass a server crt file pass the parameter options.certFile as a file path to the server crt.

To pass a client crt file use options.caFile as the path, if you want a client cert you must also pass a server cert.


var moog = require('node-moog');

// Set the options to your specific configuration.
var options = {'url':'https://hostname:8881',
    'authUser':'user',
    'authPass':'****',
    'certFile' : '../ssl/server.crt',
    'caFile' : '../ssl/client.crt'
    };

// Create a proforma event
var moogEvent = new moog.MoogEvent();
// Init a connection object
var moogRest = moog.moogREST(options);

When creating the Proforma you can pass a partial MoogEvent as a default, if not, default values will be provided for you.

Submit an event

Very simple to now submit an event to the REST LAM


moogEvent.description = 'My new description';
// Many defaults are set for you.
moogRest.sendEvent(moogEvent,callback());

The moogEvent can be a single event or an array of events

The submit is an event emitter and will currently provide 2 events, ok and error

NOTE: These may change/expand in the future to give more detail on the event progress


moogRest.sendEvent(moogEvent, function (res, rtn) {
    if (rtn == 200) {
        console.log('moogRest message sent, return code: ' + rtn);
        console.log('moogRest result: ' + res.message);
        process.exit(0);
    } else {
        console.log('moogRest - ' + rtn);
        console.log('moogRest - ' + res);
        process.exit(1);
    }
});

Use a Proxy

To use an outbound proxy just add your favorate agent.

Example code using proxy-agent.

var ProxyAgent = require('proxy-agent');
var proxyUri = process.env.http_proxy || 'http://user:[email protected]:3128';

var options = {
    url: 'https://moogtest/rest_lam',
    authUser: 'moog_user',
    authPass: '****',
    agent: new ProxyAgent(proxyUri)
};
var moogEvent = new moog.MoogEvent();
var moogREST = moog.moogREST(options);

Additional fields can be added to the event object and they will be passed to the overflow property of the alert.