Moogsoft AIOps REST Client for Node.js
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 = MoogEvent; myEvent = ; myEventdescription = '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 = ;
auth_token is optional and depends on the REST LAM configuration.
var moogRest = ;
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 = ; // 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 eventvar moogEvent = ;// Init a connection objectvar moogRest = moog;
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
moogEventdescription = 'My new description';// Many defaults are set for you.moogRest;
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;
Use a Proxy
To use an outbound proxy just add your favorate agent.
Example code using proxy-agent.
var ProxyAgent = ;var proxyUri = processenvhttp_proxy || 'http://user:pass@proxy.host:3128'; var options = url: 'https://moogtest/rest_lam' authUser: 'moog_user' authPass: '****' agent: proxyUri;var moogEvent = ;var moogREST = moog;
Additional fields can be added to the event object and they will be passed to the overflow property of the alert.