employ config.js
parent
9adcc807dd
commit
84f77f3813
15
prom.md
15
prom.md
|
|
@ -3,7 +3,7 @@
|
||||||
The goal of this version is to offer a few basic metrics for
|
The goal of this version is to offer a few basic metrics for
|
||||||
initial testing. The set of supported metrics can be extended.
|
initial testing. The set of supported metrics can be extended.
|
||||||
|
|
||||||
The current implementation is
|
The current implementation is partly
|
||||||
[unconventional](https://prometheus.io/docs/instrumenting/writing_exporters)
|
[unconventional](https://prometheus.io/docs/instrumenting/writing_exporters)
|
||||||
in that it creates new metrics each time but does not register a
|
in that it creates new metrics each time but does not register a
|
||||||
custom collector. Reasons are that the exporter should
|
custom collector. Reasons are that the exporter should
|
||||||
|
|
@ -17,18 +17,13 @@ of `multiparty-meeting` but connected as an interactive client.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
| `.env` | description |
|
See `prometheus` in `server/config/config.example.js` for options and
|
||||||
|--------|-------|
|
applicable defaults.
|
||||||
| `DEBUG` | e.g. `*WARN*,*ERROR*,*:prom` for debugging |
|
|
||||||
| `PROM_DEIDENTIFY` | if set, deidentify IP addresses |
|
|
||||||
| `PROM_NUMERIC` | if set, show numerical IP addresses |
|
|
||||||
| `PROM_PORT` | if set, enable exporter on this port |
|
|
||||||
| `PROM_QUIET` | if set, include fewer labels |
|
|
||||||
|
|
||||||
If `multiparty-meeting` was installed with
|
If `multiparty-meeting` was installed with
|
||||||
[`mm-absible`](https://github.com/misi/mm-ansible)
|
[`mm-absible`](https://github.com/misi/mm-ansible)
|
||||||
it may be necessary to open the `iptables` firewall that was established
|
it may be necessary to open the `iptables` firewall for incoming TCP traffic
|
||||||
with `ferm` for incoming TCP traffic on `PROM_PORT`.
|
on the allocated port (see `/etc/ferm/ferm.conf`).
|
||||||
|
|
||||||
## Metrics
|
## Metrics
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -342,4 +342,13 @@ module.exports =
|
||||||
maxIncomingBitrate : 1500000
|
maxIncomingBitrate : 1500000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Prometheus exporter
|
||||||
|
/*
|
||||||
|
prometheus: {
|
||||||
|
deidentify: false, // deidentify IP addresses
|
||||||
|
numeric: false, // show numeric IP addresses
|
||||||
|
port: 8889, // allocated port
|
||||||
|
quiet: false // include fewer labels
|
||||||
|
}
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -52,33 +52,6 @@ set_value = function(key, m, labels, v) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addr = async function(ip, port) {
|
|
||||||
if ('PROM_DEIDENTIFY' in process.env) {
|
|
||||||
let a = ip.split('.')
|
|
||||||
for (let i = 0; i < a.length - 2; i++) {
|
|
||||||
a[i] = 'xx';
|
|
||||||
}
|
|
||||||
return `${a.join('.')}:${port}`;
|
|
||||||
}
|
|
||||||
else if ('PROM_NUMERIC' in process.env) {
|
|
||||||
return `${ip}:${port}`;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
try {
|
|
||||||
let a = await resolver.reverse(ip);
|
|
||||||
ip = a[0];
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
logger.error(`reverse DNS query failed: ${ip} ${err.code}`);
|
|
||||||
}
|
|
||||||
return `${ip}:${port}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
quiet = function(s) {
|
|
||||||
return 'PROM_QUIET' in process.env ? '' : s;
|
|
||||||
}
|
|
||||||
|
|
||||||
collect = async function(registry, rooms, peers) {
|
collect = async function(registry, rooms, peers) {
|
||||||
|
|
||||||
metrics = function(subsystem) {
|
metrics = function(subsystem) {
|
||||||
|
|
@ -191,46 +164,64 @@ collect = async function(registry, rooms, peers) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = async function(rooms, peers) {
|
module.exports = async function(rooms, peers, config) {
|
||||||
try {
|
|
||||||
logger.debug(`PROM_DEIDENTIFY=${process.env.PROM_DEIDENTIFY}`);
|
addr = async function(ip, port) {
|
||||||
logger.debug(`PROM_NUMERIC=${process.env.PROM_NUMERIC}`);
|
if (config.deidentify) {
|
||||||
logger.debug(`PROM_PORT=${process.env.PROM_PORT}`);
|
let a = ip.split('.')
|
||||||
logger.debug(`PROM_QUIET=${process.env.PROM_QUIET}`);
|
for (let i = 0; i < a.length - 2; i++) {
|
||||||
let s_port = process.env.PROM_PORT;
|
a[i] = 'xx';
|
||||||
if (!s_port) {
|
}
|
||||||
logger.info('exporter disabled');
|
return `${a.join('.')}:${port}`;
|
||||||
|
}
|
||||||
|
else if (config.numeric) {
|
||||||
|
return `${ip}:${port}`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let n_port = Number(s_port);
|
try {
|
||||||
if (Number.isNaN(n_port)) {
|
let a = await resolver.reverse(ip);
|
||||||
throw new TypeError(`PROM_PORT has illegal value: ${s_port}`);
|
ip = a[0];
|
||||||
}
|
}
|
||||||
|
catch (err) {
|
||||||
mediasoup.observer.on('newworker', worker => {
|
logger.error(`reverse DNS query failed: ${ip} ${err.code}`);
|
||||||
logger.debug(`observing newworker ${worker.pid} #${workers.size}`);
|
}
|
||||||
workers.set(worker.pid, worker);
|
return `${ip}:${port}`;
|
||||||
worker.observer.on('close', () => {
|
|
||||||
logger.debug(`observing close worker ${worker.pid} #${workers.size - 1}`);
|
|
||||||
workers.delete(worker.pid);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
let app = express();
|
|
||||||
app.get('/', async (req, res) => {
|
|
||||||
logger.debug(`GET ${req.originalUrl}`);
|
|
||||||
let registry = new prom.Registry();
|
|
||||||
await collect(registry, rooms, peers);
|
|
||||||
res.set('Content-Type', registry.contentType);
|
|
||||||
let data = registry.metrics();
|
|
||||||
res.end(data);
|
|
||||||
});
|
|
||||||
let server = app.listen(n_port, () => {
|
|
||||||
address = server.address();
|
|
||||||
logger.info(`listening ${address.address}:${address.port}`);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
quiet = function(s) {
|
||||||
|
return config.quiet ? '' : s;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
logger.debug(`config.deidentify=${config.deidentify}`);
|
||||||
|
logger.debug(`config.numeric=${config.numeric}`);
|
||||||
|
logger.debug(`config.port=${config.port}`);
|
||||||
|
logger.debug(`config.quiet=${config.quiet}`);
|
||||||
|
|
||||||
|
mediasoup.observer.on('newworker', worker => {
|
||||||
|
logger.debug(`observing newworker ${worker.pid} #${workers.size}`);
|
||||||
|
workers.set(worker.pid, worker);
|
||||||
|
worker.observer.on('close', () => {
|
||||||
|
logger.debug(`observing close worker ${worker.pid} #${workers.size - 1}`);
|
||||||
|
workers.delete(worker.pid);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
let app = express();
|
||||||
|
app.get('/', async (req, res) => {
|
||||||
|
logger.debug(`GET ${req.originalUrl}`);
|
||||||
|
let registry = new prom.Registry();
|
||||||
|
await collect(registry, rooms, peers);
|
||||||
|
res.set('Content-Type', registry.contentType);
|
||||||
|
let data = registry.metrics();
|
||||||
|
res.end(data);
|
||||||
|
});
|
||||||
|
let server = app.listen(config.port || 8889, () => {
|
||||||
|
address = server.address();
|
||||||
|
logger.info(`listening ${address.address}:${address.port}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,9 @@ async function run()
|
||||||
await interactiveServer(rooms, peers);
|
await interactiveServer(rooms, peers);
|
||||||
|
|
||||||
// start Prometheus exporter
|
// start Prometheus exporter
|
||||||
await promExporter(rooms, peers);
|
if (config.prometheus) {
|
||||||
|
await promExporter(rooms, peers, config.prometheus);
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof(config.auth) === 'undefined')
|
if (typeof(config.auth) === 'undefined')
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue