Socket
Socket
Sign inDemoInstall

good

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

good

Server and process monitoring plugin


Version published
Weekly downloads
6.7K
increased by5.96%
Maintainers
1
Weekly downloads
 
Created
Source

good Logo

hapi process monitoring

Build Status

The 'Monitor' should be configured using a 'hapi' server instead of calling the 'Monitor' constructor directly.

hapi comes with a built-in process monitor for three types of events:

  • System and process performance (ops) - CPU, memory, disk, and other metrics.
  • Requests logging (request) - framework and application generated logs generated during the lifecycle of each incoming request.
  • General events (log) - logging information not bound to a specific request such as system errors, background processing, configuration errors, etc. Described in General Events Logging.

The monitor is off by default and can be turned on using the monitor server option. To use the default settings, simply set the value to true. Applications with multiple server instances, each with its own monitor should only include one log subscription per destination as general events (log) are a process-wide facility and will result in duplicated log events. To override some or all of the defaults, set monitor to an object with the following optional settings:

  • broadcastInterval - the interval in milliseconds to send collected events to 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.
  • extendedRequests - determines if the full request log is sent or only the event summary. Defaults to false.
  • requestsEvent - the event type used to capture completed requests. Defaults to 'tail'. Options are:
    • 'response' - the response was sent but request tails may still be pending.
    • 'tail' - the response was sent and all request tails completed.
  • subscribers - 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 or console. Defaults to a console subscription to all three. To disable the console output for the server instance pass an empty array into the subscribers "console" configuration.

For example:

var options = {
    monitor: {
        subscribers: {
            console: ['ops', 'request', 'log'],
            'http://localhost/logs': ['log']
        }
    }
};

Disabling hapi console output:

var options = {
    monitor: {
        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 = {
    monitor: {
        subscribers: {
            console: { tags: ['error'], events: ['log'] }
        }
    }
};

Keywords

FAQs

Package last updated on 05 Mar 2013

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc