@stephen-shopopop/node-metrics
    Preparing search index...

    Provides a metrics server for exposing application and process metrics.

    The MetricsServer class initializes and manages a web server that exposes metrics endpoints for Prometheus scraping and real-time metrics streaming. It supports graceful startup and shutdown, notifies observers of server events, and provides access to collected metrics such as event loop delay, memory usage, and CPU statistics.

    • The / endpoint returns dashboard UI
    • The /metrics endpoint returns Prometheus-formatted metrics.
    • The /metrics-stream endpoint provides a real-time event stream of metrics updates. curl -H Accept:text/event-stream http://localhost:9090/metrics-stream
    • Observers are notified of server lifecycle events and incoming requests.
    Index

    Constructors

    Methods

    • Gracefully shuts down the metrics server.

      Notifies observers that the metrics server is stopping and then closes the underlying web server.

      Returns Promise<void>

      A promise that resolves when the server has been successfully closed.

    • Retrieves the address information associated with the server.

      Returns undefined | AddressInfo

      The address information if available; otherwise, undefined.

    • Starts the metrics server on the specified port.

      Initializes a web server using the provided port and sets up a fetch callback to handle incoming requests. Notifies observers about the server startup and stores the server and address instances for later use.

      Parameters

      • port: number

        The port number on which the metrics server should listen.

      • OptionalappName: `${string}-${string}`

        (Optional) The application name in the format ${string}-${string}.

      Returns Promise<void>

      A promise that resolves when the server has started.