A simple and easy to use module for Prometheus metric exporting.
  • TypeScript 100%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Holly bc006e9312
All checks were successful
Build for NodeJS / build (25.x) (push) Successful in 5m8s
Bump Dependencies.
2026-04-22 14:43:15 +01:00
.forgejo/workflows Add basic test framework. 2026-02-05 16:36:08 +00:00
.idea Run test server. 2026-02-19 09:57:26 +00:00
interfaces Add basic test framework. 2026-02-05 16:36:08 +00:00
objects Add basic test framework. 2026-02-05 16:36:08 +00:00
test Add basic test framework. 2026-02-05 16:36:08 +00:00
tooling Add basic test framework. 2026-02-05 16:36:08 +00:00
.gitignore Release v2.0.0 - Break all the things. 2026-02-05 11:07:33 +00:00
.npmignore fix spelling and add readme 2024-07-03 00:45:37 +01:00
index.ts Add basic test framework. 2026-02-05 16:36:08 +00:00
LICENSE Release v2.0.0 - Break all the things. 2026-02-05 11:07:33 +00:00
package-lock.json Bump Dependencies. 2026-04-22 14:43:15 +01:00
package.json Bump Dependencies. 2026-04-22 14:43:15 +01:00
README.md fix spelling and add readme 2024-07-03 00:45:37 +01:00
tsconfig.json Migrate to TypeScript 6.x + NodeNext 2026-03-25 09:45:57 +00:00

simple-prom

A simple and easy to use module for Prometheus metric exporting.

Usage

Create an instance of SimpleProm using SimpleProm.init

import SimpleProm from "simple-prom";

const instance = SimpleProm.init({});

See IConfig for config values to use in SimpleProm.init

Self hosted usage

SimpleProm can self host it's own http server for metrics polling, simple pass "selfHost: true" in the init config.

const instance = SimpleProm.init({
	selfHost: true,
	selfHostPort: 1337 // Optional, defaults to 9100
});

Use your own http server

Simply passing an empty config {} will get you what you want here, to get the metrics data call getMetricText() on your SimpleProm instance. You can then use it as you normally would with anything, in this example with express:

const instance = SimpleProm.init({});

req.get("/metrics", (req, res) => res.end(instance.getMetricText()));

Creating metrics

To add a metric call the addMetric method on your SimpleProm instance, passing in a metric object.

Currently supported metric types are:

Support for all metric types is planned.

Example for Counter:

const instance = SimpleProm.init({});

const httpRequests = instance.addMetric(new Counter("app_http_requests_handled"));
httpRequests.setHelpText("The number of HTTP requests handled since startup");
httpRequests.add(1);

Example for Gauge:

const instance = SimpleProm.init({});

const onlineUsers = instance.addMetric(new Gauge("app_online_users"));
onlineUsers.setHelpText("The number of online users");
onlineUsers.Value = 1234;