Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
prom-nodejs-client
Advanced tools
This Node.js library facilitates the seamless transmission of Prometheus data to a Prometheus server using prom-client
. The primary function, metricsLogError
, allows the pushing of error logs to Prometheus, aiding in error monitoring and analysis.
metricsLogError(controller, error)
controller
(string): Specifies the controller or component where the error occurred.error
(Error): Represents the error object to be logged.npm install prom-nodejs-client
To integrate the library with an Express application:
import express from "express";
import promMid from "prom-nodejs-client";
/**
* Express middleware for handling metrics requests.
* @module metricsRoute
*/
const metricsRoute = express();
/**
* Middleware for collecting and exposing Prometheus metrics.
* @function
* @param {Object} options - Options for configuring the Prometheus middleware.
* @param {string} options.metricsPath - The path for exposing the metrics endpoint.
* @param {boolean} options.collectDefaultMetrics - Whether to collect default metrics.
* @param {number[]} options.requestDurationBuckets - Buckets for request duration histogram.
* @param {number[]} options.requestLengthBuckets - Buckets for request length histogram.
* @param {number[]} options.responseLengthBuckets - Buckets for response length histogram.
*/
metricsRoute.use(
promMid({
metricsPath: "/metrics",
collectDefaultMetrics: true,
requestDurationBuckets: [0.02, 0.05, 0.1, 0.5, 1, 10],
requestLengthBuckets: [512, 1024, 5120, 10240, 51200, 102400],
responseLengthBuckets: [512, 1024, 5120, 10240, 51200, 102400],
})
);
export default metricsRoute;
/**
* Metrics route for Prometheus
*/
app.use(metricsRoute);
Ensure the .env
file contains the following configuration:
SERVICE_NAME=service-name
import { metricsLogError } from "prom-nodejs-client";
const controllerName = "ExampleController";
const error = new Error("Example error message");
metricsLogError(controllerName, error);
Contributions are welcome! Feel free to open issues or pull requests.
FAQs
## Overview
The npm package prom-nodejs-client receives a total of 9 weekly downloads. As such, prom-nodejs-client popularity was classified as not popular.
We found that prom-nodejs-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.