Skip to content
Snippets Groups Projects
Unverified Commit 8e634be1 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento Committed by GitHub
Browse files

New metric to track oplog queue (#17142)

* New metric to track oplog queue

* Reuse mongo instance from getMongoInfo
parent 7656ae1b
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ import connect from 'connect';
import _ from 'underscore';
import { Meteor } from 'meteor/meteor';
import { Info } from '../../../utils';
import { Info, getOplogInfo } from '../../../utils/server';
import { Migrations } from '../../../migrations';
import { settings } from '../../../settings';
import { Statistics } from '../../../models';
......@@ -57,6 +57,7 @@ metrics.version = new client.Gauge({ name: 'rocketchat_version', labelNames: ['v
metrics.migration = new client.Gauge({ name: 'rocketchat_migration', help: 'migration versoin' });
metrics.instanceCount = new client.Gauge({ name: 'rocketchat_instance_count', help: 'instances running' });
metrics.oplogEnabled = new client.Gauge({ name: 'rocketchat_oplog_enabled', labelNames: ['enabled'], help: 'oplog enabled' });
metrics.oplogQueue = new client.Gauge({ name: 'rocketchat_oplog_queue', labelNames: ['queue'], help: 'oplog queue' });
metrics.oplog = new client.Counter({
name: 'rocketchat_oplog',
help: 'summary of oplog operations',
......@@ -134,6 +135,9 @@ const setPrometheusData = async () => {
metrics.totalPrivateGroupMessages.set(statistics.totalPrivateGroupMessages, date);
metrics.totalDirectMessages.set(statistics.totalDirectMessages, date);
metrics.totalLivechatMessages.set(statistics.totalLivechatMessages, date);
const oplogQueue = getOplogInfo().mongo._oplogHandle?._entryQueue?.length || 0;
metrics.oplogQueue.set(oplogQueue, date);
};
const app = connect();
......
import { MongoInternals } from 'meteor/mongo';
export function getOplogInfo() {
const { mongo } = MongoInternals.defaultRemoteCollectionDriver();
const oplogEnabled = Boolean(mongo._oplogHandle && mongo._oplogHandle.onOplogEntry);
return { oplogEnabled, mongo };
}
function fallbackMongoInfo() {
let mongoVersion;
let mongoStorageEngine;
const { mongo } = MongoInternals.defaultRemoteCollectionDriver();
const oplogEnabled = Boolean(mongo._oplogHandle && mongo._oplogHandle.onOplogEntry);
const { oplogEnabled, mongo } = getOplogInfo();
try {
const { version } = Promise.await(mongo.db.command({ buildinfo: 1 }));
......@@ -34,9 +40,7 @@ export function getMongoInfo() {
let mongoVersion;
let mongoStorageEngine;
const { mongo } = MongoInternals.defaultRemoteCollectionDriver();
const oplogEnabled = Boolean(mongo._oplogHandle && mongo._oplogHandle.onOplogEntry);
const { oplogEnabled, mongo } = getOplogInfo();
try {
const { version, storageEngine } = Promise.await(mongo.db.command({ serverStatus: 1 }));
......
......@@ -7,7 +7,7 @@ export { roomTypes } from './lib/roomTypes';
export { RoomTypeRouteConfig, RoomTypeConfig, RoomSettingsEnum, RoomMemberActions, UiTextContext } from '../lib/RoomTypeConfig';
export { RoomTypesCommon } from '../lib/RoomTypesCommon';
export { isDocker } from './functions/isDocker';
export { getMongoInfo } from './functions/getMongoInfo';
export { getMongoInfo, getOplogInfo } from './functions/getMongoInfo';
export { getUserAvatarURL } from '../lib/getUserAvatarURL';
export { slashCommands } from '../lib/slashCommand';
export { getUserNotificationPreference } from '../lib/getUserNotificationPreference';
......
......@@ -6,8 +6,8 @@ import { Meteor } from 'meteor/meteor';
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
import { SystemLogger } from '../../app/logger';
import { settings } from '../../app/settings';
import { Info, getMongoInfo } from '../../app/utils';
import { settings } from '../../app/settings/server';
import { Info, getMongoInfo } from '../../app/utils/server';
import { Users } from '../../app/models/server';
import { sendMessagesToAdmins } from '../lib/sendMessagesToAdmins';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment