1.0.3 • Published 4 years ago

@adityav_one/express-prometheus-exporter v1.0.3

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
4 years ago

express-prometheus-exporter

This package exports prometheus metrics for an express application. It's dependent on prom-client.

Metrics exported

  • Server metrics collected using collectDefaultMetrics
  • Garbage collection metrics
  • HTTP metrics
    • Response time in seconds
    • Request size in bytes
    • Response size in bytes

Usage

const prometheusExporter = require('express-prometheus-exporter)(options);
app.use(prometheusExporter.middleware);

Options

  • metricsPath: The endpoint to be exposed in the application and scraped by prometheus. default: /metrics
  • prefix: Metrics will be prefixed by this value if provided. default: ''
  • urlFormatter: It is used to format the route based on the following options. - ignoreRegex: It is used to ignore the regex part in routes. default: false - replaceInBaseUrl: It is used to replace a string/pattern in the base url with empty string. default: false
  • additionalLabels: It is used to add additional labels on top of default ones. default: ['method', 'route', 'code']. This accepts an object with the key as label name and the value as the callback function to be invoked when generating labels. The default params to the callback function provided is req and res.
      additionalLabels: { 'type': (req, res) => { // perform any action } }
  • logger: Logger to be used while performing various actions on metrics. Uses Logger instance as default.

Methods

Pass configuration as per ExporterConfig

  • createCounter
  • createGauge
  • createHistogram
  • createSummary
  • resetRegister
1.0.2

4 years ago

1.0.1

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago