import type { PipelineMetricCollectionResponse, StatisticsResponse } from '@rdi-ui/sdk/models'; import type { PipelineStateValueV1 } from '../pipeline/types'; export interface ClassicProcessorMetrics { data_streams?: { totals?: { total?: number; pending?: number; inserted?: number; updated?: number; deleted?: number; filtered?: number; rejected?: number; deduplicated?: number; }; streams?: Record; }; processing_performance?: Record; rdi_pipeline_status?: { rdi_version?: string; address?: string; run_status?: string; sync_mode?: string; }; connections?: Record; clients?: Record; offsets?: Record; snapshot_status?: string; } export interface FlinkProcessorMetrics { data_streams?: { totals?: { incoming?: number; pending?: number; inserted?: number; updated?: number; deleted?: number; filtered?: number; rejected?: number; }; streams?: Record; }; /** The processor's read side of the internal RDI stream. */ source?: { connected?: boolean; pending_ack?: number; }; /** The processor's write side to the target database. */ sink?: { connected?: boolean; /** Timestamp of the last write to the target; null until the first write. */ last_modified?: string | null; }; throughput?: { source_records_per_sec?: number; sink_records_per_sec?: number; }; /** Utilization in ms per second (0–1000); the three shares sum to ≤1000. */ utilization?: { busy_time_ms_per_sec?: number; idle_time_ms_per_sec?: number; back_pressured_time_ms_per_sec?: number; }; checkpoint?: Record; job?: { status?: string; /** How long the job has been in its current status. */ status_time_ms?: number; num_restarts?: number; }; } export type ClassicProcessorMetricCollection = PipelineMetricCollectionResponse & { metrics: ClassicProcessorMetrics; }; export type FlinkProcessorMetricCollection = PipelineMetricCollectionResponse & { metrics: FlinkProcessorMetrics; }; /** * The collector's streaming (CDC) sample as reported by the source connector. * Numeric flags (`Connected`, `IsGtidModeEnabled`) are 1/0; every field is * optional — a collector build that does not report a metric omits it rather * than sending a default. * * Engine-specific attributes (MySQL/MariaDB, MongoDB, Oracle LogMiner) share * this object: a connector only ever reports the attributes its engine * documents, and the normalizer sorts them into per-engine blocks. */ export interface CollectorStreamingMetrics { Connected?: number; MilliSecondsBehindSource?: number; MilliSecondsSinceLastEvent?: number; TotalNumberOfEventsSeen?: number; TotalNumberOfCreateEventsSeen?: number; TotalNumberOfUpdateEventsSeen?: number; TotalNumberOfDeleteEventsSeen?: number; NumberOfEventsFiltered?: number; NumberOfErroneousEvents?: number; QueueRemainingCapacity?: number; QueueTotalCapacity?: number; CurrentQueueSizeInBytes?: number; MaxQueueSizeInBytes?: number; SourceEventPosition?: string | Record; LastTransactionId?: string; IsGtidModeEnabled?: number; GtidSet?: string; NumberOfSkippedEvents?: number; NumberOfDisconnects?: number; NumberOfNotWellFormedTransactions?: number; NumberOfLargeTransactions?: number; NumberOfPrimaryElections?: number; CurrentScn?: number; OldestScn?: number; OldestScnAgeInMilliseconds?: number; CommittedScn?: number; OffsetScn?: number; MiningSessionLowerBounds?: number; MiningSessionUpperBounds?: number; CurrentRedoLogFileNames?: string | string[]; LogSwitchCount?: number; NumberOfActiveTransactions?: number; TotalChangesCount?: number; LagFromSourceInMilliseconds?: number; MinLagFromSourceInMilliseconds?: number; MaxLagFromSourceInMilliseconds?: number; AverageBatchProcessingThroughput?: number; LastBatchProcessingThroughput?: number; LastDurationOfFetchQueryInMilliseconds?: number; MaxDurationOfFetchQueryInMilliseconds?: number; LastBatchProcessingTimeInMilliseconds?: number; MaxBatchProcessingTimeInMilliseconds?: number; TotalResultSetNextTimeInMilliseconds?: number; LastCommitDurationInMilliseconds?: number; MaxCommitDurationInMilliseconds?: number; ErrorCount?: number; ScnFreezeCount?: number; UnparsableDdlCount?: number; AbandonedTransactionCount?: number; } /** * The collector's snapshot sample. The five `Snapshot*` flags are 1/0 and * describe one state; `MilliSecondsSinceLastEvent` here is the snapshot * sample, never merged with the streaming one. */ export interface CollectorSnapshotMetrics { SnapshotRunning?: number; SnapshotPaused?: number; SnapshotAborted?: number; SnapshotCompleted?: number; SnapshotSkipped?: number; TotalTableCount?: number; RemainingTableCount?: number; SnapshotDurationInSeconds?: number; SnapshotPausedDurationInSeconds?: number; MilliSecondsSinceLastEvent?: number; TotalNumberOfEventsSeen?: number; NumberOfEventsFiltered?: number; NumberOfErroneousEvents?: number; /** MongoDB snapshot-context disconnect count. */ NumberOfDisconnects?: number; QueueRemainingCapacity?: number; QueueTotalCapacity?: number; CurrentQueueSizeInBytes?: number; MaxQueueSizeInBytes?: number; } export interface CollectorMetrics { streaming?: CollectorStreamingMetrics; snapshot?: CollectorSnapshotMetrics; } export type CollectorMetricCollection = PipelineMetricCollectionResponse & { metrics: CollectorMetrics; }; export type RdiMetricCollection = ClassicProcessorMetricCollection | FlinkProcessorMetricCollection | CollectorMetricCollection | PipelineMetricCollectionResponse; /** * Flink job state. `statusTimeMs` is how long the job has been in `status` * (the processor's uptime while running); `numRestarts` counts job restarts. */ export interface ProcessorJobMetrics { status?: string; statusTimeMs?: number; numRestarts?: number; } /** The processor's read side of the internal RDI stream. */ export interface ProcessorSourceMetrics { connected?: boolean; pendingAck?: number; } /** The processor's write side to the target database. */ export interface ProcessorSinkMetrics { connected?: boolean; /** ISO 8601 timestamp of the last write; undefined until the first write. */ lastModified?: string; } export interface ProcessorThroughputMetrics { sourceRecordsPerSec?: number; sinkRecordsPerSec?: number; } /** Utilization in ms per second (0–1000); the three shares sum to ≤1000. */ export interface ProcessorUtilizationMetrics { busyMsPerSec?: number; idleMsPerSec?: number; backPressuredMsPerSec?: number; } /** * Processor internals that only the flink processor reports. `undefined` on * classic pipelines — consumers must render their "not reported" state. */ export interface ProcessorDetails { job?: ProcessorJobMetrics; source?: ProcessorSourceMetrics; sink?: ProcessorSinkMetrics; throughput?: ProcessorThroughputMetrics; utilization?: ProcessorUtilizationMetrics; } /** * Normalized streaming (CDC) sample of one source's collector. Absent wire * fields stay `undefined` — a missing value must never surface as 0. */ export interface CollectorStreamingStats { connected?: boolean; msBehindSource?: number; msSinceLastEvent?: number; totalEventsSeen?: number; createEventsSeen?: number; updateEventsSeen?: number; deleteEventsSeen?: number; eventsFiltered?: number; erroneousEvents?: number; queueRemainingCapacity?: number; queueTotalCapacity?: number; currentQueueSizeBytes?: number; maxQueueSizeBytes?: number; /** Connector-specific position of the last source event, serialized. */ sourceEventPosition?: string; lastTransactionId?: string; /** Source database disconnect count (MySQL, MariaDB, MongoDB streaming). */ disconnects?: number; } /** Normalized snapshot sample of one source's collector. */ export interface CollectorSnapshotStats { running?: boolean; paused?: boolean; aborted?: boolean; completed?: boolean; skipped?: boolean; totalTableCount?: number; remainingTableCount?: number; durationSeconds?: number; pausedDurationSeconds?: number; msSinceLastEvent?: number; totalEventsSeen?: number; eventsFiltered?: number; erroneousEvents?: number; /** MongoDB snapshot-context disconnect count. */ disconnects?: number; queueRemainingCapacity?: number; queueTotalCapacity?: number; currentQueueSizeBytes?: number; maxQueueSizeBytes?: number; } /** MySQL/MariaDB streaming attributes (binlog/GTID health). */ export interface MysqlCollectorStats { gtidModeEnabled?: boolean; gtidSet?: string; skippedEvents?: number; notWellFormedTransactions?: number; largeTransactions?: number; } /** * MongoDB streaming attributes. Disconnect counts live on the per-phase * samples (`streaming`/`snapshot`), not here — they are counted separately * per phase. */ export interface MongodbCollectorStats { primaryElections?: number; } /** Oracle LogMiner attributes: SCN/mining state, performance/lag, errors. */ export interface OracleCollectorStats { currentScn?: number; oldestScn?: number; oldestScnAgeMs?: number; committedScn?: number; offsetScn?: number; miningSessionLowerBounds?: number; miningSessionUpperBounds?: number; currentRedoLogFiles?: string; logSwitchCount?: number; activeTransactions?: number; totalChanges?: number; lagFromSourceMs?: number; minLagFromSourceMs?: number; maxLagFromSourceMs?: number; averageBatchThroughput?: number; lastBatchThroughput?: number; lastFetchQueryMs?: number; maxFetchQueryMs?: number; lastBatchProcessingMs?: number; maxBatchProcessingMs?: number; totalResultSetNextMs?: number; lastCommitDurationMs?: number; maxCommitDurationMs?: number; errorCount?: number; scnFreezeCount?: number; unparsableDdlCount?: number; abandonedTransactionCount?: number; } /** * One source's collector metrics. `state` is derived from the streaming / * snapshot flags with the same rules the v2 status path uses, so the Metrics * page and the pipeline status never disagree about the phase. * * The engine blocks (`mysql`, `mongodb`, `oracle`) are present only when the * collector reported at least one attribute of that engine — which block is * meaningful for a given source is decided by the source's configured type, * not by data presence. */ export interface SourceCollectorMetrics { state: PipelineStateValueV1; streaming?: CollectorStreamingStats; snapshot?: CollectorSnapshotStats; mysql?: MysqlCollectorStats; mongodb?: MongodbCollectorStats; oracle?: OracleCollectorStats; } /** * What `getProcessorMetrics` serves: the backward-compatible statistics view * plus the processor's own blocks when the processor reports them. */ export interface MonitoringStatistics extends StatisticsResponse { processor?: ProcessorDetails; /** * Per-source collector metrics, keyed by source name (same keys as * `StatusResponse.collectorStates`). Absent on the v1 API, which has no * collector metric collections — consumers must render their "not * reported" state. */ collectors?: Record; }