twentyhq / twenty

Building a modern alternative to Salesforce, powered by the community.
https://twenty.com
Other
20.3k stars 2.25k forks source link

Monitoring: Create a cron to monitor messageChannelSyncStatus #5898

Closed bosiraphael closed 4 months ago

bosiraphael commented 5 months ago

Currently we lack tools to correctly monitor the message channel sync statuses.

greptile-apps[bot] commented 5 months ago
  1. Create a new cron job file in src/cron/monitorMessageChannelSyncStatus.ts.
  2. Import necessary services:
    import { messagingTelemetryService } from '../services/messagingTelemetryService';
    import { getMessageChannelSyncStatuses } from '../repositories/messageChannelRepository';
  3. Implement the cron job logic:
    const monitorMessageChannelSyncStatus = async () => {
    const statuses = await getMessageChannelSyncStatuses();
    statuses.forEach(status => {
    messagingTelemetryService.track(`message_channel.monitoring.sync_status.${status}`);
    });
    };
  4. Schedule the cron job in src/cron/index.ts:
    
    import { monitorMessageChannelSyncStatus } from './monitorMessageChannelSyncStatus';

schedule('0 ', monitorMessageChannelSyncStatus); // Runs every hour


5. Add necessary monitoring graphs in Grafana by querying the emitted events `message_channel.monitoring.sync_status.[SYNC_STATUS]`.

### References