bigbluebutton-Github/bigbluebutton-html5/imports/startup/server/prom-metrics/index.js
germanocaumo 6f1e1d4f4a refactor(prom-html5): serve endpoint via meteor instead of http server +
- separate backend/frontend metrics, only add metrics related to the role
- add role and instance labels
2021-11-05 16:31:23 +00:00

36 lines
755 B
JavaScript

import Agent from './promAgent.js';
import {
METRICS_PREFIX,
METRIC_NAMES,
buildMetrics
} from './metrics.js';
const {
enabled: METRICS_ENABLED,
path: METRICS_PATH,
collectDefaultMetrics: COLLECT_DEFAULT_METRICS,
} = Meteor.settings.private.prometheus
? Meteor.settings.private.prometheus
: { enabled: false };
const PrometheusAgent = new Agent({
path: METRICS_PATH,
prefix: METRICS_PREFIX,
collectDefaultMetrics: COLLECT_DEFAULT_METRICS,
role: process.env.BBB_HTML5_ROLE,
instanceId: parseInt(process.env.INSTANCE_ID, 10) || 1,
});
if (METRICS_ENABLED) {
PrometheusAgent.injectMetrics(buildMetrics());
PrometheusAgent.start();
}
export {
METRIC_NAMES,
METRICS_PREFIX,
Agent,
PrometheusAgent,
};