Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
hapi process monitoring
The 'Monitor' should be configured using a 'hapi' server instead of calling the 'Monitor' constructor directly.
good is a process monitor for three types of events:
Applications with multiple server instances, each with its own monitor should only include one log subscription per destination as general events
are a process-wide facility and will result in duplicated log events. To override some or all of the defaults, set options
to an object with the following
optional settings:
broadcastInterval
- the interval in milliseconds to send collected events to HTTP subscribers. 0 means send immediately. Defaults to 0.opsInterval
- the interval in milliseconds to sample system and process performance metrics. Minimum is 100ms. Defaults to 15 seconds.leakDetection
- determines if memory leaks should be detected. Any leaks will be logged with ops data. Defaults to false.extendedRequests
- determines if the full request log is sent or only the event summary. Defaults to false.maxLogSize
- the maximum byte size to allow log files to become before creating a new log file. Default is 0 which means log files will not be split. When split the log file extension will be incremented by 1. The initial log file has an extension of .001.requestsEvent
- the event type used to capture completed requests. Defaults to 'tail'. Options are:
requestsTimeout
- the number of milliseconds to set the request timeout to when broadcasting to HTTP subscriberssubscribers
- an object where each key is a destination and each value is either an array or object with an array of subscriptions. The subscriptions that are available are ops, request, and log. The destination can be a URI, file or directory path, and console. Defaults to a console subscriber for ops, request, and log events. To disable the console output for the server instance pass an empty array into the subscribers "console" configuration.For example:
var options = {
subscribers: {
console: ['ops', 'request', 'log'],
'http://localhost/logs': ['log'],
'/tmp/logs/': ['request', 'log']
}
};
hapi.plugin.require('good', options, function (err) {
if (!err) {
// Plugin loaded successfully
}
});
Disabling console output:
var options = {
subscribers: {
console: [],
'http://localhost/logs': ['log']
}
};
Log messages are created with tags. Usually a log will include a tag to indicate if it is related to an error or info along with where the message originates. If, for example, the console should only output error's that were logged you can use the following configuration:
var options = {
subscribers: {
console: { tags: ['error'], events: ['log'] }
}
};
Log file subscribers can either be a file or a directory. When logging to a file (there isn't a trailing slash) then the files will be written with the file name in the provided path. Otherwise, when the subscriber is a directory the log files will be named with a timestamp and placed in the directory. All log files will have .001, .002, and .003 formatted extensions. Below is an example of file and directory subscribers:
var options = {
subscribers: {
'/logs/good_log': { tags: ['error'], events: ['log'] }, // Creates good_log.001 file in /logs/
'/logs/': { events: ['request'] } // Creates {timestamp}.001 file in /logs/
}
};
When good broadcasts data to a remote endpoint it sends json that has the following properties:
schema
- the value of 'schemaName' in the settings. Default is 'good.v1'host
- the operating system hostnameappVer
- the version of goodtimestamp
- the current time of the serverevents
- an array of the events that are subscribed toGood includes a 'replay' script that is capabale of replaying any request events found in a log file. Below is the command to use to execute 'replay':
replay -l log.json -h host -n #_of_concurrent_requests
FAQs
Server and process monitoring plugin
The npm package good receives a total of 5,471 weekly downloads. As such, good popularity was classified as popular.
We found that good demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.