Adding Prometheus metrics

This commit adds a '/metrics' endpoint in the API that can be exploited by Prometheus.

This endpoint returns:

- the number of connected sockets
- the number of users per room
- common NodeJS and system metrics

WARNING: this endpoint is public right now and should be protected
This commit is contained in:
David Négrier 2020-06-09 11:49:23 +02:00
parent bdb01f3103
commit af6924a27c
6 changed files with 66 additions and 5 deletions

View file

@ -6,6 +6,7 @@ import {Application, Request, Response} from 'express';
import bodyParser = require('body-parser');
import * as http from "http";
import {MapController} from "./Controller/MapController";
import {PrometheusController} from "./Controller/PrometheusController";
class App {
public app: Application;
@ -13,6 +14,7 @@ class App {
public ioSocketController: IoSocketController;
public authenticateController: AuthenticateController;
public mapController: MapController;
public prometheusController: PrometheusController;
constructor() {
this.app = express();
@ -29,6 +31,7 @@ class App {
this.ioSocketController = new IoSocketController(this.server);
this.authenticateController = new AuthenticateController(this.app);
this.mapController = new MapController(this.app);
this.prometheusController = new PrometheusController(this.app, this.ioSocketController);
}
// TODO add session user
@ -49,4 +52,4 @@ class App {
}
}
export default new App().server;
export default new App().server;