Skip to content
Development
Command

/migration-observability

Migration monitoring, CDC, and observability infrastructure

From plugin
wshobson-agents
39k95 skills139 agents95 commands
Install
$ npx -y skills add wshobson/agents --agent claude-code

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/migration-observability

Context preview

What this command does when you run it.

Migration monitoring, CDC, and observability infrastructure

Command definition

migration-observability.md
description: Migration monitoring, CDC, and observability infrastructure
version: "1.0.0"
tags: [database, cdc, debezium, kafka, prometheus, grafana, monitoring]
tool_access: [Read, Write, Edit, Bash, WebFetch]

Migration Observability and Real-time Monitoring

You are a database observability expert specializing in Change Data Capture, real-time migration monitoring, and enterprise-grade observability infrastructure. Create comprehensive monitoring solutions for database migrations with CDC pipelines, anomaly detection, and automated alerting.

Context

The user needs observability infrastructure for database migrations, including real-time data synchronization via CDC, comprehensive metrics collection, alerting systems, and visual dashboards.

Requirements

$ARGUMENTS

Instructions

1. Observable MongoDB Migrations

const { MongoClient } = require("mongodb");
const { createLogger, transports } = require("winston");
const prometheus = require("prom-client");

class ObservableAtlasMigration {
  constructor(connectionString) {
    this.client = new MongoClient(connectionString);
    this.logger = createLogger({
      transports: [
        new transports.File({ filename: "migrations.log" }),
        new transports.Console(),
      ],
    });
    this.metrics = this.setupMetrics();
  }

  setupMetrics() {
    const register = new prometheus.Registry();

    return {
      migrationDuration: new prometheus.Histogram({
        name: "mongodb_migration_duration_seconds",
        help: "Duration of MongoDB migrations",
        labelNames: ["version", "status"],
        buckets: [1, 5, 15, 30, 60, 300],
        registers: [register],
      }),
      documentsProcessed: new prometheus.Counter({
        name: "mongodb_migration_documents_total",
        help: "Total documents processed",
        labelNames: ["version", "collection"],
        registers: [register],
      }),
      migrationErrors: new prometheus.Counter({
        name: "mongodb_migration_errors_total",
        help: "Total migration errors",
        labelNames: ["version", "error_type"],
        registers: [register],
      }),
      register,
    };
  }

  async migrate() {
    await this.client.connect();
    const db = this.client.db();

    for (const [version, migration] of this.migrations) {
      await this.executeMigrationWithObservability(db, version, migration);
    }
  }

  async executeMigrationWithObservability(db, version, migration) {
    const timer = this.metrics.migrationDuration.startTimer({ version });
    const session = this.client.startSession();

    try {
      this.logger.info(`Starting migration ${version}`);

      await session.withTransaction(async () => {
        await migration.up(db, session, (collection, count) => {
          this.metrics.documentsProcessed.inc(
            {
              version,
              collection,
            },
            count,
          );
        });
      });

      timer({ status: "success" });
      this.logger.info(`Migration ${version} completed`);
    } catch (error) {
      this.metrics.migrationErrors.inc({
        version,
        error_type: error.name,
      });
      timer({ status: "failed" });
      throw error;
    } finally {
      await session.endSession();
    }
  }
}

2. Change Data Capture with Debezium

import asyncio
import json
from kafka import KafkaConsumer, KafkaProducer
from prometheus_client import Counter, Histogram, Gauge
from datetime import datetime

class CDCObservabilityManager:
    def __init__(self, config):
        self.config = config
        self.metrics = self.setup_metrics()

    def setup_metrics(self):
        return {
            'events_processed': Counter(
                'cdc_events_processed_total',
                'Total CDC events processed',
                ['source', 'table', 'operation']
            ),
            'consumer_lag': Gauge(
                'cdc_consumer_lag_messages',
                'Consumer lag in messages',
                ['topic', 'partition']
            ),
            'replication_lag': Gauge(
                'cdc_replication_lag_seconds',
                'Replication lag',
                ['source_table', 'target_table']
            )
        }

    async def setup_cdc_pipeline(self):
        self.consumer = KafkaConsumer(
            'database.changes',
            bootstrap_servers=self.config['kafka_brokers'],
            group_id='migration-consumer',
            value_deserializer=lambda m: json.loads(m.decode('utf-8'))
        )

        self.producer = KafkaProducer(
            bootstrap_servers=self.config['kafka_brokers'],
            value_serializer=lambda v: json.dumps(v).encode('utf-8')
        )

    async def process_cdc_events(self):
        for message in self.consumer:
            event = self.parse_cdc_event(message.value)

            self.metrics['events_processed'].labels(
                source=event.source_db,
                table=event.table,
                operation=event.operation
            ).inc()

            await self.apply_to_target(
                event.table,
                event.operation,
                event.data,
                event.timestamp
            )

    async def setup_debezium_connector(self, source_config):
        connector_config = {
            "name": f"migration-connector-{source_config['name']}",
            "config": {
                "connector.class": "io.debezium.connector.postgresql.PostgresConnector",
                "database.hostname": source_config['host'],
                "database.port": source_config['port'],
                "database.dbname": source_config['database'],
                "plugin.name": "pgoutput",
                "heartbeat.interval.ms": "10000"
            }
        }

        response = requests.post(
            f"{self.config['kafka_connect_url']}/connectors",
            json=connector_config
        )

3. Enterprise Monitoring and Aler

Read more
Ships withwshobson-agents

Production-ready agentic workflow building blocks: 94 plugins, 203 agents, 175 skills, 109 commands — built for Claude Code and consumed natively by OpenAI Codex CLI, Cursor, OpenCode, Gemini CLI, and GitHub Copilot from a single Markdown source.

Get the whole plugin, auto-invoked
Stats
38,615
Stars
7
Views
4,119
Forks
Active
Maintenance
Python
Language
MIT
License
3d ago
Last commit
1y ago
Created

Repo: wshobson/agents