Socket
Socket
Sign inDemoInstall

express-prom-bundle

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-prom-bundle

express middleware with popular prometheus metrics in one bundle


Version published
Weekly downloads
278K
decreased by-14.5%
Maintainers
1
Weekly downloads
 
Created

What is express-prom-bundle?

The express-prom-bundle package is a middleware for Express.js that integrates Prometheus metrics collection and reporting. It allows you to easily monitor the performance and health of your Express applications by exposing various metrics that Prometheus can scrape.

What are express-prom-bundle's main functionalities?

Basic Setup

This code demonstrates the basic setup of express-prom-bundle in an Express application. It initializes the middleware and includes it in the app, which will start collecting and exposing metrics.

const express = require('express');
const promBundle = require('express-prom-bundle');

const app = express();
const metricsMiddleware = promBundle({ includeMethod: true });

app.use(metricsMiddleware);

app.get('/', (req, res) => {
  res.send('Hello World!');
});

app.listen(3000, () => {
  console.log('Server is running on port 3000');
});

Custom Metrics

This code demonstrates how to create and use custom metrics with express-prom-bundle. It shows how to define a custom counter and increment it in a route handler.

const express = require('express');
const promBundle = require('express-prom-bundle');
const promClient = require('prom-client');

const app = express();
const metricsMiddleware = promBundle({ includeMethod: true });

app.use(metricsMiddleware);

const customCounter = new promClient.Counter({
  name: 'custom_counter',
  help: 'Example of a custom counter',
});

app.get('/increment', (req, res) => {
  customCounter.inc();
  res.send('Counter incremented');
});

app.listen(3000, () => {
  console.log('Server is running on port 3000');
});

Custom Metrics Endpoint

This code demonstrates how to customize the endpoint where Prometheus metrics are exposed. By setting the `metricsPath` option, you can change the default `/metrics` endpoint to a custom path.

const express = require('express');
const promBundle = require('express-prom-bundle');

const app = express();
const metricsMiddleware = promBundle({ includeMethod: true, metricsPath: '/custom-metrics' });

app.use(metricsMiddleware);

app.get('/', (req, res) => {
  res.send('Hello World!');
});

app.listen(3000, () => {
  console.log('Server is running on port 3000');
});

Other packages similar to express-prom-bundle

Keywords

FAQs

Package last updated on 23 Sep 2017

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