fix spelling and add readme
This commit is contained in:
parent
9c3dc2e152
commit
553cff0165
6 changed files with 64 additions and 5 deletions
|
@ -1,6 +1,10 @@
|
||||||
.github/*
|
.github/*
|
||||||
index.ts
|
index.ts
|
||||||
tsconfig.json
|
tsconfig.json
|
||||||
|
lib/test/*
|
||||||
|
interfaces/*
|
||||||
|
objects/*
|
||||||
|
test/*
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
logs
|
logs
|
||||||
|
|
55
README.md
55
README.md
|
@ -1,3 +1,58 @@
|
||||||
# simple-prom
|
# simple-prom
|
||||||
|
|
||||||
A simple and easy to use module for Prometheus metric exporting.
|
A simple and easy to use module for Prometheus metric exporting.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Create an instance of SimpleProm using `SimpleProm.init`
|
||||||
|
```ts
|
||||||
|
import SimpleProm from "simple-prom";
|
||||||
|
|
||||||
|
const instance = SimpleProm.init({});
|
||||||
|
```
|
||||||
|
See [IConfig](https://git.eusv.net/Catgirl.Enterprises/simple-prom/src/branch/master/interfaces/IConfig.ts) 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.
|
||||||
|
```ts
|
||||||
|
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:
|
||||||
|
```ts
|
||||||
|
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:
|
||||||
|
- [Counter](https://prometheus.io/docs/concepts/metric_types/#counter)
|
||||||
|
- [Gauge](https://prometheus.io/docs/concepts/metric_types/#gauge)
|
||||||
|
|
||||||
|
Support for all metric types is planned.
|
||||||
|
|
||||||
|
Example for Counter:
|
||||||
|
```ts
|
||||||
|
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:
|
||||||
|
```ts
|
||||||
|
const instance = SimpleProm.init({});
|
||||||
|
|
||||||
|
const onlineUsers = instance.addMetric(new Gauge("app_online_users"));
|
||||||
|
onlineUsers.setHelpText("The number of online users");
|
||||||
|
onlineUsers.Value = 1234;
|
||||||
|
```
|
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "simple-prom",
|
"name": "simple-prom",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "simple-prom",
|
"name": "simple-prom",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"funky-array": "^1.0.0"
|
"funky-array": "^1.0.0"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "simple-prom",
|
"name": "simple-prom",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"description": "A simple and easy to use module for Prometheus metric exporting.",
|
"description": "A simple and easy to use module for Prometheus metric exporting.",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
import SimpleProm from "../index";
|
import SimpleProm from "../index";
|
||||||
import Counter from "../objects/Counter";
|
import Counter from "../objects/Counter";
|
||||||
import Gauge from "../objects/Guage";
|
import Gauge from "../objects/Gauge";
|
||||||
|
|
||||||
const instance = SimpleProm.init({
|
const instance = SimpleProm.init({
|
||||||
selfHost: true
|
selfHost: true
|
||||||
|
|
Loading…
Reference in a new issue