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

crow-metrics-viz

v2.0.6

Published

express plugin that exports and displays crow metrics

Downloads

6

Readme

crow-metrics-viz

Viz is a small plugin for crow-metrics that exposes your server's metrics over HTTP using express. It collects snapshots over a rolling window (one hour, by default) and graphs this data on a web page.

Usage

There are two ways to construct the service:

  • viz(metrics: Metrics, options: VizOptions = {}): express.Router

    Create an express router that will respond to a path with the viz interface. This is useful if your server is already using express for other requests.

    • express - the express module or a compatible one
    • metrics - a crow Metrics object
    • options - passed to the RingBuffer:
      • span: number - how many milliseconds to buffer (default is one hour, or 3600 * 1000)
      • prometheus: boolean - if true, a prometheus document will be hosted at /metrics

    For example:

    const express = require("express");
    const { Metrics } = require("crow-metrics");
    const { viz } = require("crow-metrics-viz");
    
    const app = express();
    const metrics = Metrics.create();
    app.use("/admin/viz", viz(express, metrics));

    This will add the viz paths under /admin/viz on your express server.

  • startVizServer(metrics: Metrics, port: number = 8080, options: VizOptions = {})

    Start up the viz site on a devoted port with a new instance of express.

    For example:

    const { Metrics } = require("crow-metrics");
    const { startVizServer } = require("crow-metrics-viz");
    
    const metrics = Metrics.create();
    startVizServer(metrics, 9090);

    This will create a page at http://localhost:9090/.

Paths

  • /

    A small webpage that loads the content from /history.json and draws an SVG graph for each one. This is meant to give a quick human-readable overview of the server instance's metrics.

  • /current.json

    A JSON object where each key is the name of a metric, and each value is its current value.

  • /history.json

    A JSON object where each key is the name of a metric, and each value is an array of the metric's values over the past hour (or whatever span you configured), in order from oldest to newest. A special key "@timestamp" gives an array of the corresponding timestamps for these values, in epoch seconds.

  • /metrics

    A prometheus-formatted plaintext metrics snapshot, if requested in options.

License

Apache 2 (open-source) license, included in LICENSE.txt.

Authors

@robey - Robey Pointer [email protected]