<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Kafka on lo0 — Tech Blog</title><link>https://blog.lo0.es/en/tags/kafka/</link><description>Recent content in Kafka on lo0 — Tech Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Thu, 04 Jun 2026 11:00:00 +0200</lastBuildDate><atom:link href="https://blog.lo0.es/en/tags/kafka/index.xml" rel="self" type="application/rss+xml"/><item><title>Debezium and CDC: the notary who hears changes before anyone asks</title><link>https://blog.lo0.es/en/posts/debezium-cdc-notary-who-hears-changes/</link><pubDate>Thu, 04 Jun 2026 11:00:00 +0200</pubDate><guid>https://blog.lo0.es/en/posts/debezium-cdc-notary-who-hears-changes/</guid><description>&lt;h2 id="tldr">TL;DR&lt;/h2>
&lt;p>Change Data Capture (CDC) with Debezium listens to the PostgreSQL Write-Ahead Log and turns every INSERT, UPDATE and DELETE into a structured Kafka event. Unlike traditional polling (&lt;code>SELECT ... WHERE updated_at &amp;gt; ?&lt;/code>), it detects deletes, has latency in the tens of milliseconds and adds no extra load to the database. In RAG pipelines, this means that when a document is deleted from Postgres, the Qdrant chunks disappear too, automatically and in real time. The supporting infrastructure is modest: the connector uses 2-4 cores and 4-8 GB RAM to process thousands of events per second.&lt;/p>
&lt;hr>
&lt;h2 id="the-master-analogy-the-land-registry-notary">The master analogy: the land registry notary&lt;/h2>
&lt;p>Picture the land registry. Every time a flat is sold, mortgaged, or a mortgage is cancelled, the registrar records the operation in the &lt;strong>registry ledger&lt;/strong>, a chronological and immutable journal. If you want to know what has changed in the registry, you have two options.&lt;/p>
&lt;p>&lt;strong>Option A (polling):&lt;/strong> you send someone every 5 minutes with a list of properties to ask &amp;ldquo;has anything changed?&amp;rdquo;. Problems: if a title was cancelled (DELETE), the property no longer exists by the time your envoy arrives, and there is no trace of it. If 20 different departments are doing the same thing, that is 20 people pestering the registrar every 5 minutes. And the minimum latency is the interval: 5 minutes.&lt;/p>
&lt;p>&lt;strong>Option B (Debezium):&lt;/strong> you hire a &lt;strong>notary&lt;/strong> who sits right at the registrar&amp;rsquo;s desk. Every time the registrar signs an operation into the ledger, the notary notes it down immediately and notifies whoever needs to know. Title cancellations included, because the notary sees them as clearly as any other operation: he was there when it was signed.&lt;/p>
&lt;p>In this analogy:&lt;/p>
&lt;ul>
&lt;li>The &lt;strong>registry ledger&lt;/strong> is the PostgreSQL &lt;strong>WAL&lt;/strong> (Write-Ahead Log).&lt;/li>
&lt;li>The &lt;strong>notary&lt;/strong> is the &lt;strong>Debezium connector&lt;/strong>.&lt;/li>
&lt;li>The notary&amp;rsquo;s &lt;strong>bookmark&lt;/strong>, which guarantees he loses no page even if he steps out for a moment, is the &lt;strong>logical replication slot&lt;/strong>.&lt;/li>
&lt;li>The &lt;strong>messenger&lt;/strong> who carries the notifications to interested parties is &lt;strong>Kafka&lt;/strong> (or Redpanda, or NATS JetStream).&lt;/li>
&lt;/ul>
&lt;p>We will pick this thread up in every section. When a technical detail is unclear, go back to the image of the notary.&lt;/p>
&lt;hr>
&lt;h2 id="1-the-problem-cdc-solves">1. The problem CDC solves&lt;/h2>
&lt;p>The most common synchronisation pattern between services sharing PostgreSQL is periodic polling:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">SELECT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">content&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">updated_at&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">documents&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">WHERE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">updated_at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">$&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">ORDER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">BY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">updated_at&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">LIMIT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">1000&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This pattern has three structural problems.&lt;/p>
&lt;p>&lt;strong>DELETEs are invisible.&lt;/strong> When you delete a row, &lt;code>updated_at&lt;/code> is not updated: the row is gone. The next time the poller queries, the row does not exist and there is no way to know it ever did. In a RAG pipeline, this means &lt;strong>orphan chunks in Qdrant&lt;/strong>: the document no longer exists in Postgres, but its vectors keep polluting search results.&lt;/p>
&lt;p>&lt;strong>The minimum latency is the interval.&lt;/strong> If the poller runs every 5 seconds, average latency is 2.5 seconds. For near-real-time synchronisation (dashboards, alerts, RAG with frequently changing documents), that is too much.&lt;/p>
&lt;p>&lt;strong>Load scales with the number of consumers.&lt;/strong> If 10 services poll the same table every 5 seconds, that is 10 × 12 = 120 queries/minute producing no useful work; they only check whether there is anything new. On large tables with complex indexes, that is real load on the database.&lt;/p>
&lt;p>CDC inverts the model: &lt;strong>the database notifies, the consumers listen&lt;/strong>. Zero polling, zero extra load, DELETEs included, latency in the tens of milliseconds.&lt;/p>
&lt;hr>
&lt;h2 id="2-what-the-postgresql-wal-is">2. What the PostgreSQL WAL is&lt;/h2>
&lt;h3 id="the-operations-journal">The operations journal&lt;/h3>
&lt;p>The Write-Ahead Log (WAL) is the chronological, immutable record of every operation Postgres performs. Before modifying any data page on disk, Postgres writes the operation to the WAL. That sequence, log first then data, is what guarantees durability (the D in ACID) and enables crash recovery: if Postgres dies mid-transaction, on restart it replays the WAL to return the database to a consistent state.&lt;/p>
&lt;p>The WAL is the &lt;strong>registry ledger&lt;/strong> of our analogy: chronological, immutable, complete.&lt;/p>
&lt;h3 id="physical-vs-logical-replication">Physical vs logical replication&lt;/h3>
&lt;p>PostgreSQL supports two WAL-based replication modes:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Physical replication:&lt;/strong> it replicates disk blocks verbatim. The standby receives the same bytes as the primary. It serves high availability and failover, but the target must be an exact copy of Postgres; you cannot send the changes to an external application.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Logical replication:&lt;/strong> instead of disk blocks, it replicates &lt;strong>semantic operations&lt;/strong>: &amp;ldquo;the row with id=42 was inserted into table &lt;code>documents&lt;/code> with these values&amp;rdquo;. The target can be anything that understands the protocol: another Postgres, Debezium, or any custom consumer.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>CDC uses logical replication. It is what lets Debezium understand &amp;ldquo;what changed and in which table&amp;rdquo; rather than &amp;ldquo;which disk block changed at which offset&amp;rdquo;.&lt;/p>
&lt;h3 id="the-replication-slot-the-notarys-bookmark">The replication slot: the notary&amp;rsquo;s bookmark&lt;/h3>
&lt;p>A &lt;strong>logical replication slot&lt;/strong> is a persistent cursor in the WAL. Postgres keeps a record of how far into the WAL each slot has consumed. While a slot exists, Postgres &lt;strong>guarantees it will not discard the WAL segments the slot has not yet read&lt;/strong>.&lt;/p>
&lt;p>This is exactly the notary&amp;rsquo;s bookmark: even if the notary goes out for lunch, the ledger stays open at the last page he read. When he comes back, he carries on from exactly where he left off, having lost nothing.&lt;/p>
&lt;p>The risk is the inverse: &lt;strong>if the notary never comes back&lt;/strong>, the bookmark stops the registrar from archiving the old pages. If the Debezium connector goes down and does not recover for hours, the WAL grows indefinitely on disk until the slot is deleted manually or the consumer starts consuming again. This is called &lt;strong>WAL disk blowup&lt;/strong> and is the most important operational risk of Debezium.&lt;/p>
&lt;p>Mandatory monitoring:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">SELECT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">slot_name&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">confirmed_flush_lsn&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">pg_current_wal_lsn&lt;/span>&lt;span class="p">(),&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">pg_wal_lsn_diff&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">pg_current_wal_lsn&lt;/span>&lt;span class="p">(),&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">confirmed_flush_lsn&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">lag_bytes&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">pg_replication_slots&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">WHERE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">slot_type&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;logical&amp;#39;&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="the-pgoutput-plugin">The pgoutput plugin&lt;/h3>
&lt;p>The WAL stores operations in an internal binary format. For Debezium to understand them, Postgres needs to &lt;strong>decode&lt;/strong> them into a readable format. The &lt;code>pgoutput&lt;/code> decoding plugin, included in the Postgres core since version 10, does exactly that: it translates the binary WAL events into messages with the before/after structure of each row.&lt;/p>
&lt;p>Debezium uses &lt;code>pgoutput&lt;/code> by default. It requires no external extensions (unlike the &lt;code>wal2json&lt;/code> plugin that was popular before Postgres 10).&lt;/p>
&lt;hr>
&lt;h2 id="3-debezium-architecture">3. Debezium architecture&lt;/h2>
&lt;h3 id="the-connector-as-a-kafka-connect-plugin">The connector as a Kafka Connect plugin&lt;/h3>
&lt;p>Debezium is not a standalone service; it is a plugin for the &lt;strong>Kafka Connect&lt;/strong> framework. Kafka Connect manages the connector&amp;rsquo;s lifecycle (start, stop, reconnection, offset tracking) and provides the parallelism and fault tolerance infrastructure.&lt;/p>
&lt;p>The connector talks to Postgres through the logical replication protocol (not over JDBC), using the credentials of a user with the &lt;code>REPLICATION&lt;/code> role.&lt;/p>
&lt;pre tabindex="0">&lt;code>PostgreSQL (WAL + pgoutput)
│
│ logical replication protocol
▼
Debezium Connector (Kafka Connect worker)
│
│ Kafka Producer API
▼
Kafka topic: rag.public.documents
│
▼
Consumer (Qdrant sync, audit log, fine-tuning pipeline...)
&lt;/code>&lt;/pre>&lt;h3 id="structure-of-a-debezium-event">Structure of a Debezium event&lt;/h3>
&lt;p>Each change in the table becomes a JSON message with this structure:&lt;/p>
&lt;p>&lt;strong>INSERT (&lt;code>&amp;quot;op&amp;quot;: &amp;quot;c&amp;quot;&lt;/code> — create):&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-json" data-lang="json">&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;before&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="kc">null&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;after&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;id&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="mi">42&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;content&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;Contrato de arrendamiento...&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;tenant_id&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;acme&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;updated_at&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="mi">1748934000000&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;op&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;c&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;source&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;version&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;2.7.0.Final&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;connector&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;postgresql&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;db&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;rag_db&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;schema&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;public&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;table&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;documents&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;lsn&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="mi">29823948&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;txId&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="mi">1047&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;ts_ms&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="mi">1748934000123&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>DELETE (&lt;code>&amp;quot;op&amp;quot;: &amp;quot;d&amp;quot;&lt;/code>):&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-json" data-lang="json">&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;before&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;id&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="mi">42&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;content&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;Contrato de arrendamiento...&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;tenant_id&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;acme&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;updated_at&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="mi">1748934000000&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;after&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="kc">null&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;op&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;d&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;source&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;lsn&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="mi">29824102&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;txId&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="mi">1051&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;ts_ms&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="mi">1748934060200&lt;/span> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The &lt;code>before&lt;/code> field holds the row&amp;rsquo;s previous state, available because Postgres can be configured with &lt;strong>REPLICA IDENTITY FULL&lt;/strong> to include the complete row in the WAL on delete or update. Without that setting, &lt;code>before&lt;/code> contains only the primary key.&lt;/p>
&lt;p>&lt;strong>This is the key for the RAG pipeline&lt;/strong>: the DELETE event carries the document &lt;code>id&lt;/code>. The consumer uses it to delete every associated chunk in Qdrant with a &lt;code>doc_id = 42&lt;/code> filter. Without CDC, those chunks would never have been deleted.&lt;/p>
&lt;h3 id="initial-snapshot">Initial snapshot&lt;/h3>
&lt;p>When the connector starts for the first time (or after a reset), it cannot begin consuming the WAL from &amp;ldquo;the beginning of time&amp;rdquo;, only from the moment the slot was created. How does it guarantee the consistency of the initial state?&lt;/p>
&lt;p>Through a &lt;strong>transactional snapshot&lt;/strong>: the connector opens a transaction in &lt;code>REPEATABLE READ&lt;/code> mode, exports the snapshot ID (&lt;code>pg_export_snapshot()&lt;/code>), and does a full &lt;code>SELECT&lt;/code> of the configured tables inside that transaction. It then starts consuming the WAL from the snapshot&amp;rsquo;s LSN. That way there is no gap: the snapshot covers the state up to an instant, and the WAL covers from that instant onwards.&lt;/p>
&lt;h3 id="smt-transformations-single-message-transforms">SMT transformations (Single Message Transforms)&lt;/h3>
&lt;p>Before emitting the event to the Kafka topic, the connector can apply inline transformations called &lt;strong>SMT&lt;/strong>. Common use cases:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Filtering sensitive columns&lt;/strong> (&lt;code>ReplaceField&lt;/code> with &lt;code>blacklist&lt;/code>): strip &lt;code>password_hash&lt;/code>, &lt;code>phone_number&lt;/code> before they reach the topic.&lt;/li>
&lt;li>&lt;strong>Adding metadata&lt;/strong> (&lt;code>InsertField&lt;/code>): enrich the event with a &lt;code>tenant_id&lt;/code> extracted from the original HTTP header (if it is in the row).&lt;/li>
&lt;li>&lt;strong>Conditional routing&lt;/strong> (&lt;code>Filter&lt;/code>): drop events from rows with &lt;code>status = 'draft'&lt;/code> before emitting them.&lt;/li>
&lt;/ul>
&lt;p>SMTs are pure configuration, requiring no code, and they are applied inside the connector process with no perceptible extra latency.&lt;/p>
&lt;hr>
&lt;h2 id="4-debezium-vs-the-outbox-pattern">4. Debezium vs the Outbox pattern&lt;/h2>
&lt;p>The &lt;strong>Outbox pattern&lt;/strong> is the most common alternative to pure CDC. Instead of emitting events directly to Kafka, the application writes to an &lt;code>outbox&lt;/code> table in Postgres within the same transaction that modifies the data. A separate worker reads that table and publishes the events.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Criterion&lt;/th>
&lt;th>Debezium (pure CDC)&lt;/th>
&lt;th>Outbox pattern&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;strong>Event latency&lt;/strong>&lt;/td>
&lt;td>~50-200 ms from commit&lt;/td>
&lt;td>Depends on the worker interval (typically 1-5 s)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Consistency&lt;/strong>&lt;/td>
&lt;td>At-least-once&lt;/td>
&lt;td>At-least-once&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>DELETE detection&lt;/strong>&lt;/td>
&lt;td>Native (the DELETE event includes &lt;code>before&lt;/code>)&lt;/td>
&lt;td>Only if the app writes to the outbox on delete&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Setup complexity&lt;/strong>&lt;/td>
&lt;td>High (Kafka Connect, replication slot, permissions)&lt;/td>
&lt;td>Low (an extra table plus a simple worker)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Infrastructure dependency&lt;/strong>&lt;/td>
&lt;td>Requires Kafka/Redpanda/NATS JetStream&lt;/td>
&lt;td>Postgres plus a worker; Kafka optional&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>WAL disk blowup risk&lt;/strong>&lt;/td>
&lt;td>Yes, if the slot stops consuming&lt;/td>
&lt;td>No&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Schema visibility&lt;/strong>&lt;/td>
&lt;td>Reads the table&amp;rsquo;s real schema&lt;/td>
&lt;td>The event schema is defined by the app&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Schema migration&lt;/strong>&lt;/td>
&lt;td>Needs care (events reflect DDL changes)&lt;/td>
&lt;td>More flexible (the event is whatever the app puts there)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>When to use it&lt;/strong>&lt;/td>
&lt;td>When you need DELETEs, low latency, or you cannot modify the app&lt;/td>
&lt;td>When the app controls the event domain and infrastructure is limited&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;strong>Rule of thumb:&lt;/strong> if you control the application code and do not need native DELETEs, the Outbox is simpler. If you do not control the code (legacy database, third-party application) or DELETEs are critical (a RAG pipeline with document deletion), Debezium is the right choice.&lt;/p>
&lt;hr>
&lt;h2 id="5-the-maths">5. The maths&lt;/h2>
&lt;h3 id="throughput">Throughput&lt;/h3>
&lt;p>Debezium on a connector with 4 workers can process between &lt;strong>10,000 and 50,000 events/second&lt;/strong> on modest hardware (4 cores, 8 GB RAM). The real bottleneck is not the connector but the Kafka broker: with 3 brokers and suitable partitions, Kafka can comfortably sustain 500,000 messages/second with 1 KB messages (source: public Confluent benchmarks, 2023).&lt;/p>
&lt;p>For a typical RAG pipeline with 100 documents modified per minute:&lt;/p>
$$\text{events/s} = \frac{100}{60} \approx 1{.}7 \text{ events/s}$$
&lt;p>That is 0.0034% of the connector&amp;rsquo;s capacity. Debezium will not be the bottleneck in any realistic RAG scenario.&lt;/p>
&lt;h3 id="end-to-end-latency">End-to-end latency&lt;/h3>
&lt;p>The path from a commit in Postgres to an upsert in Qdrant has these stages:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Stage&lt;/th>
&lt;th>Typical latency&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Commit in Postgres → WAL written&lt;/td>
&lt;td>&amp;lt; 1 ms (synchronous with the commit)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>WAL written → Debezium reads it (WAL lag)&lt;/td>
&lt;td>10-50 ms&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Debezium → Kafka produce (ack)&lt;/td>
&lt;td>5-20 ms&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Kafka → Consumer (poll interval)&lt;/td>
&lt;td>0-100 ms (configurable)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Consumer → Qdrant upsert/delete&lt;/td>
&lt;td>5-15 ms&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Typical total&lt;/strong>&lt;/td>
&lt;td>&lt;strong>30-200 ms&lt;/strong>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>With &lt;code>fetch.min.bytes=1&lt;/code> and &lt;code>fetch.max.wait.ms=10&lt;/code> on the consumer, the Kafka poll latency drops to ~10 ms. The realistic range for an optimised pipeline is &lt;strong>30-100 ms&lt;/strong>.&lt;/p>
&lt;h3 id="wal-disk-blowup-risk">WAL disk blowup risk&lt;/h3>
&lt;p>If the connector stops consuming, Postgres retains the WAL from the slot&amp;rsquo;s &lt;code>confirmed_flush_lsn&lt;/code> onwards. The retained volume grows linearly with time and the write rate:&lt;/p>
$$\text{retained WAL} = \text{write rate} \times \text{average WAL event size} \times \text{time without consuming}$$
&lt;p>Example with a moderate load (50,000 writes/hour, 500 bytes average per WAL event):&lt;/p>
$$50{,}000 \times 500 \text{ B} \times 1 \text{ h} = 25 \text{ MB/h}$$
&lt;p>With a high load (1,000,000 writes/hour):&lt;/p>
$$1{,}000{,}000 \times 500 \text{ B} \times 1 \text{ h} = 500 \text{ MB/h}$$
&lt;p>If the connector is down for 48 hours under high load: &lt;strong>24 GB of retained WAL&lt;/strong>. That can fill the disk and block Postgres completely.&lt;/p>
&lt;p>&lt;strong>Recommended alert:&lt;/strong> set an alert when &lt;code>lag_bytes &amp;gt; 1 GB&lt;/code> or when &lt;code>confirmed_flush_lsn&lt;/code> has not advanced for more than 15 minutes. See the monitoring query in section 2.&lt;/p>
&lt;hr>
&lt;h2 id="6-use-cases-in-llmops--rag">6. Use cases in LLMOps / RAG&lt;/h2>
&lt;h3 id="rag-synchronisation-with-real-deletion">RAG synchronisation with real deletion&lt;/h3>
&lt;p>This is the use case that most clearly justifies Debezium over polling. The flow:&lt;/p>
&lt;ol>
&lt;li>A user deletes document &lt;code>id=42&lt;/code> from the document management interface.&lt;/li>
&lt;li>Postgres runs &lt;code>DELETE FROM documents WHERE id = 42&lt;/code>.&lt;/li>
&lt;li>Debezium detects the DELETE in the WAL and emits the event with &lt;code>&amp;quot;op&amp;quot;: &amp;quot;d&amp;quot;&lt;/code> and &lt;code>&amp;quot;before&amp;quot;: {&amp;quot;id&amp;quot;: 42, ...}&lt;/code>.&lt;/li>
&lt;li>The consumer receives the event and runs:
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="n">qdrant_client&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">delete&lt;/span>&lt;span class="p">(&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">collection_name&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s2">&amp;#34;documents&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">points_selector&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">Filter&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">must&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">FieldCondition&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">key&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s2">&amp;#34;doc_id&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="k">match&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">MatchValue&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">value&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mi">42&lt;/span>&lt;span class="p">))])&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>Every chunk with &lt;code>doc_id=42&lt;/code> disappears from Qdrant in ~100 ms.&lt;/li>
&lt;/ol>
&lt;p>Without Debezium, those chunks would stay indefinitely, polluting retrieval results with fragments of documents that no longer exist in the source of truth.&lt;/p>
&lt;h3 id="event-sourcing-for-fine-tuning-datasets">Event sourcing for fine-tuning datasets&lt;/h3>
&lt;p>Every time a human annotator updates a row in the &lt;code>annotations&lt;/code> table (correcting an LLM output), Debezium emits the UPDATE with &lt;code>before&lt;/code> and &lt;code>after&lt;/code>. The consumer writes the pair (original_output, correction) into the dataset curation pipeline, with no need for the annotator to do anything beyond saving in the interface. The fine-tuning pipeline knows exactly what changed and when, with no polling and no risk of duplicates from overlapping time windows.&lt;/p>
&lt;h3 id="immutable-audit-log">Immutable audit log&lt;/h3>
&lt;p>WAL events are, by definition, the most faithful record of what happened in the database: they are the same data Postgres uses for crash recovery. Kafka with long retention (90 days, or size-based retention) serves as an &lt;strong>immutable audit log&lt;/strong> without modifying the application schema or adding triggers. This is particularly useful in regulated environments where traceability of data modifications is required.&lt;/p>
&lt;hr>
&lt;h2 id="7-architecture-diagram">7. Architecture diagram&lt;/h2>
&lt;div class="diagram" style="max-width:820px;margin:1.5rem auto;">
&lt;svg viewBox="0 0 820 340" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Debezium CDC architecture diagram: PostgreSQL, Debezium, Kafka, Consumer and Qdrant">
&lt;defs>
&lt;marker id="arrow-deb" markerWidth="8" markerHeight="8" refX="6" refY="3" orient="auto">&lt;path d="M0,0 L0,6 L8,3 z" fill="#64748b"/>&lt;/marker>
&lt;/defs>
&lt;rect x="0" y="0" width="820" height="340" fill="#f8f9fa" rx="8"/>
&lt;rect x="20" y="60" width="170" height="220" fill="#dbeafe" stroke="#3b82f6" stroke-width="1.5" rx="8"/>
&lt;text x="105" y="84" font-family="monospace" font-size="13" font-weight="bold" fill="#1e40af" text-anchor="middle">PostgreSQL&lt;/text>
&lt;rect x="36" y="96" width="138" height="52" fill="#bfdbfe" stroke="#3b82f6" stroke-width="1" rx="4"/>
&lt;text x="105" y="116" font-family="monospace" font-size="11" fill="#1e3a8a" text-anchor="middle">WAL&lt;/text>
&lt;text x="105" y="131" font-family="monospace" font-size="10" fill="#1e3a8a" text-anchor="middle">(registry ledger)&lt;/text>
&lt;rect x="36" y="160" width="138" height="52" fill="#bfdbfe" stroke="#3b82f6" stroke-width="1" rx="4"/>
&lt;text x="105" y="180" font-family="monospace" font-size="11" fill="#1e3a8a" text-anchor="middle">Replication slot&lt;/text>
&lt;text x="105" y="195" font-family="monospace" font-size="10" fill="#1e3a8a" text-anchor="middle">(bookmark)&lt;/text>
&lt;rect x="36" y="224" width="138" height="40" fill="#bfdbfe" stroke="#3b82f6" stroke-width="1" rx="4"/>
&lt;text x="105" y="244" font-family="monospace" font-size="11" fill="#1e3a8a" text-anchor="middle">pgoutput&lt;/text>
&lt;text x="105" y="257" font-family="monospace" font-size="10" fill="#1e3a8a" text-anchor="middle">(decoding)&lt;/text>
&lt;line x1="190" y1="170" x2="248" y2="170" stroke="#64748b" stroke-width="2" marker-end="url(#arrow-deb)"/>
&lt;text x="219" y="162" font-family="monospace" font-size="9" fill="#475569" text-anchor="middle">logical&lt;/text>
&lt;text x="219" y="173" font-family="monospace" font-size="9" fill="#475569" text-anchor="middle">replication&lt;/text>
&lt;rect x="248" y="110" width="160" height="120" fill="#dcfce7" stroke="#16a34a" stroke-width="1.5" rx="8"/>
&lt;text x="328" y="134" font-family="monospace" font-size="13" font-weight="bold" fill="#14532d" text-anchor="middle">Debezium&lt;/text>
&lt;text x="328" y="151" font-family="monospace" font-size="10" fill="#14532d" text-anchor="middle">Connector&lt;/text>
&lt;text x="328" y="168" font-family="monospace" font-size="10" fill="#166534" text-anchor="middle">(Kafka Connect)&lt;/text>
&lt;rect x="264" y="178" width="112" height="38" fill="#bbf7d0" stroke="#16a34a" stroke-width="1" rx="4"/>
&lt;text x="320" y="193" font-family="monospace" font-size="9" fill="#14532d" text-anchor="middle">op: c / u / d&lt;/text>
&lt;text x="320" y="207" font-family="monospace" font-size="9" fill="#14532d" text-anchor="middle">before + after + LSN&lt;/text>
&lt;line x1="408" y1="170" x2="464" y2="170" stroke="#64748b" stroke-width="2" marker-end="url(#arrow-deb)"/>
&lt;text x="436" y="162" font-family="monospace" font-size="9" fill="#475569" text-anchor="middle">Kafka&lt;/text>
&lt;text x="436" y="173" font-family="monospace" font-size="9" fill="#475569" text-anchor="middle">Producer&lt;/text>
&lt;rect x="464" y="110" width="150" height="120" fill="#fef9c3" stroke="#ca8a04" stroke-width="1.5" rx="8"/>
&lt;text x="539" y="134" font-family="monospace" font-size="13" font-weight="bold" fill="#713f12" text-anchor="middle">Kafka&lt;/text>
&lt;text x="539" y="151" font-family="monospace" font-size="10" fill="#713f12" text-anchor="middle">topic:&lt;/text>
&lt;text x="539" y="165" font-family="monospace" font-size="9" fill="#92400e" text-anchor="middle">rag.public.documents&lt;/text>
&lt;rect x="478" y="178" width="122" height="38" fill="#fef08a" stroke="#ca8a04" stroke-width="1" rx="4"/>
&lt;text x="539" y="193" font-family="monospace" font-size="9" fill="#713f12" text-anchor="middle">configurable retention&lt;/text>
&lt;text x="539" y="207" font-family="monospace" font-size="9" fill="#713f12" text-anchor="middle">at-least-once&lt;/text>
&lt;line x1="614" y1="170" x2="668" y2="170" stroke="#64748b" stroke-width="2" marker-end="url(#arrow-deb)"/>
&lt;text x="641" y="162" font-family="monospace" font-size="9" fill="#475569" text-anchor="middle">Kafka&lt;/text>
&lt;text x="641" y="173" font-family="monospace" font-size="9" fill="#475569" text-anchor="middle">Consumer&lt;/text>
&lt;rect x="668" y="110" width="132" height="120" fill="#fce7f3" stroke="#db2777" stroke-width="1.5" rx="8"/>
&lt;text x="734" y="134" font-family="monospace" font-size="12" font-weight="bold" fill="#831843" text-anchor="middle">Consumer&lt;/text>
&lt;rect x="682" y="146" width="104" height="36" fill="#fbcfe8" stroke="#db2777" stroke-width="1" rx="4"/>
&lt;text x="734" y="162" font-family="monospace" font-size="9" fill="#831843" text-anchor="middle">INSERT/UPDATE&lt;/text>
&lt;text x="734" y="175" font-family="monospace" font-size="9" fill="#831843" text-anchor="middle">→ upsert Qdrant&lt;/text>
&lt;rect x="682" y="190" width="104" height="28" fill="#fbcfe8" stroke="#db2777" stroke-width="1" rx="4"/>
&lt;text x="734" y="204" font-family="monospace" font-size="9" fill="#831843" text-anchor="middle">DELETE&lt;/text>
&lt;text x="734" y="215" font-family="monospace" font-size="9" fill="#831843" text-anchor="middle">→ delete Qdrant&lt;/text>
&lt;line x1="734" y1="230" x2="734" y2="288" stroke="#64748b" stroke-width="2" marker-end="url(#arrow-deb)"/>
&lt;rect x="668" y="288" width="132" height="40" fill="#ede9fe" stroke="#7c3aed" stroke-width="1.5" rx="8"/>
&lt;text x="734" y="313" font-family="monospace" font-size="12" font-weight="bold" fill="#4c1d95" text-anchor="middle">Qdrant&lt;/text>
&lt;rect x="20" y="295" width="620" height="28" fill="#f1f5f9" stroke="#94a3b8" stroke-width="1" rx="4"/>
&lt;text x="330" y="313" font-family="monospace" font-size="10" fill="#475569" text-anchor="middle">Typical end-to-end latency: 30-100 ms from commit in Postgres to upsert/delete in Qdrant&lt;/text>
&lt;/svg>
&lt;/div>
&lt;hr>
&lt;h2 id="8-minimum-configuration">8. Minimum configuration&lt;/h2>
&lt;h3 id="postgresql-enable-logical-replication">PostgreSQL: enable logical replication&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="c1">-- Requires restarting Postgres
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="k">ALTER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">SYSTEM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">SET&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">wal_level&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">logical&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">ALTER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">SYSTEM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">SET&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">max_replication_slots&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">10&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">ALTER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">SYSTEM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">SET&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">max_wal_senders&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">10&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1">-- Reload configuration (wal_level requires a full restart)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="k">SELECT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">pg_reload_conf&lt;/span>&lt;span class="p">();&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1">-- Dedicated user for Debezium
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="k">CREATE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">USER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">debezium&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">WITH&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">REPLICATION&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">LOGIN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">PASSWORD&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;cambiar_esto&amp;#39;&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">GRANT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">SELECT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">ON&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">TABLE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">public&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">documents&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">TO&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">debezium&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1">-- REPLICA IDENTITY FULL to get a complete &amp;#39;before&amp;#39; on DELETEs and UPDATEs
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="k">ALTER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">TABLE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">public&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">documents&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">REPLICA&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">IDENTITY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">FULL&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="debezium-connector-kafka-connect-rest-api">Debezium connector (Kafka Connect REST API)&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-json" data-lang="json">&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;postgres-debezium&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;config&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;connector.class&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;io.debezium.connector.postgresql.PostgresConnector&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;database.hostname&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;postgres&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;database.port&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;5432&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;database.user&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;debezium&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;database.password&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;cambiar_esto&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;database.dbname&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;rag_db&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;topic.prefix&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;rag&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;table.include.list&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;public.documents&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;plugin.name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;pgoutput&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;slot.name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;debezium_rag&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;publication.autocreate.mode&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;filtered&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;snapshot.mode&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;initial&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;tombstones.on.delete&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;true&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;transforms&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;unwrap&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;transforms.unwrap.type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;io.debezium.transforms.ExtractNewRecordState&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;transforms.unwrap.drop.tombstones&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;false&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;transforms.unwrap.delete.handling.mode&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;rewrite&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Register the connector:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">curl -X POST http://kafka-connect:8083/connectors &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> -H &lt;span class="s1">&amp;#39;Content-Type: application/json&amp;#39;&lt;/span> &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> -d @connector-config.json
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Check its status:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">curl http://kafka-connect:8083/connectors/postgres-debezium/status
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="minimal-consumer-in-python">Minimal consumer in Python&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">confluent_kafka&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">Consumer&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">qdrant_client&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">QdrantClient&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">qdrant_client.models&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">Filter&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">FieldCondition&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">MatchValue&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kn">import&lt;/span> &lt;span class="nn">json&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">consumer&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">Consumer&lt;/span>&lt;span class="p">({&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s2">&amp;#34;bootstrap.servers&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;kafka:9092&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s2">&amp;#34;group.id&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;qdrant-sync&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s2">&amp;#34;auto.offset.reset&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;earliest&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s2">&amp;#34;enable.auto.commit&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="kc">False&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">})&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">consumer&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">subscribe&lt;/span>&lt;span class="p">([&lt;/span>&lt;span class="s2">&amp;#34;rag.public.documents&amp;#34;&lt;/span>&lt;span class="p">])&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">qdrant&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">QdrantClient&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;qdrant&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">port&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mi">6333&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">while&lt;/span> &lt;span class="kc">True&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">msg&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">consumer&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">poll&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">timeout&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mf">0.1&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="n">msg&lt;/span> &lt;span class="ow">is&lt;/span> &lt;span class="kc">None&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">continue&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">event&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">json&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">loads&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">msg&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">value&lt;/span>&lt;span class="p">())&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">op&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">event&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">get&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;op&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="n">op&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;c&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s2">&amp;#34;u&amp;#34;&lt;/span>&lt;span class="p">):&lt;/span> &lt;span class="c1"># INSERT or UPDATE&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">doc&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">event&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;after&amp;#34;&lt;/span>&lt;span class="p">]&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># ... vectorise and upsert into Qdrant&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">elif&lt;/span> &lt;span class="n">op&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="s2">&amp;#34;d&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="c1"># DELETE&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">doc_id&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">event&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;before&amp;#34;&lt;/span>&lt;span class="p">][&lt;/span>&lt;span class="s2">&amp;#34;id&amp;#34;&lt;/span>&lt;span class="p">]&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">qdrant&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">delete&lt;/span>&lt;span class="p">(&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">collection_name&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s2">&amp;#34;documents&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">points_selector&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">Filter&lt;/span>&lt;span class="p">(&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">must&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">FieldCondition&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">key&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s2">&amp;#34;doc_id&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="k">match&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">MatchValue&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">value&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="n">doc_id&lt;/span>&lt;span class="p">))]&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">consumer&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">commit&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;hr>
&lt;h2 id="9-on-premise-deployment">9. On-premise deployment&lt;/h2>
&lt;p>The Debezium stack does not compete for GPU. On a node with &lt;strong>4×H100 SXM (320 GB, NVLink)&lt;/strong> serving the inference LLM, the CDC pipeline runs entirely on general-purpose (CPU-only) nodes:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Component&lt;/th>
&lt;th>Recommended resources&lt;/th>
&lt;th>Role&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Kafka Connect + Debezium&lt;/td>
&lt;td>2-4 cores, 4-8 GB RAM&lt;/td>
&lt;td>Read the WAL, emit events&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Kafka brokers (×3)&lt;/td>
&lt;td>4 cores, 32 GB RAM each&lt;/td>
&lt;td>High availability, retention&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Qdrant-sync consumer&lt;/td>
&lt;td>2 cores, 4 GB RAM&lt;/td>
&lt;td>Vectorise plus upsert/delete&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Qdrant&lt;/td>
&lt;td>8 cores, 64 GB RAM&lt;/td>
&lt;td>Vector store&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The Debezium connector is notably light: in production at 10,000 events/second, the connector typically uses less than 1 core and 2 GB of RAM. JVM memory (Kafka Connect runs on the JVM) must be capped explicitly with &lt;code>-Xmx4g&lt;/code> to stop the GC from causing pauses.&lt;/p>
&lt;p>For high availability, Kafka Connect supports &lt;strong>distributed&lt;/strong> mode with multiple workers. If a worker dies, the connector is reassigned automatically to another worker within seconds, and the replication slot guarantees no events are lost during the switchover.&lt;/p>
&lt;hr>
&lt;h2 id="what-we-have-not-covered">What we have not covered&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Debezium with MySQL, MongoDB and Oracle&lt;/strong>: each connector uses the native log mechanism (binlog on MySQL, oplog on MongoDB, LogMiner on Oracle). The resulting event API is similar, but the configuration details and limitations differ.&lt;/li>
&lt;li>&lt;strong>Debezium Server&lt;/strong>: standalone mode without Kafka Connect, with direct sinks to HTTP, S3, Redis Streams or NATS. Useful when the Kafka infrastructure is too complex for the use case.&lt;/li>
&lt;li>&lt;strong>Schema Registry&lt;/strong>: how Avro with Confluent Schema Registry or Apicurio manages event schema evolution (adding columns, changing types) without breaking existing consumers.&lt;/li>
&lt;li>&lt;strong>Exactly-once semantics&lt;/strong>: why at-least-once is enough for most RAG cases (an idempotent upsert into Qdrant with the same vector does no harm) and when exactly-once is needed (financial counters, inventory deductions).&lt;/li>
&lt;li>&lt;strong>Outbox pattern plus Debezium combined&lt;/strong>: Debezium reading the &lt;code>outbox&lt;/code> table instead of the business table&amp;rsquo;s WAL directly, the Transactional Outbox + CDC pattern that combines the best of both worlds.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="see-also">See also&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/postgresql-qdrant-rag-ingestion-postman-syncing-two-worlds/">PostgreSQL + Qdrant: ingestion through microservices&lt;/a> — the post where CDC with Debezium is used as an alternative to the outbox pattern to keep PostgreSQL and Qdrant in sync.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/rag-corpus-curation-active-librarian/">RAG corpus curation: fundamentals&lt;/a> — the corpus curation that Debezium keeps fresh in near real time.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/six-stage-llmops-pipeline-architecture-and-deep-dive/">LLMOps pipeline: the six stages&lt;/a> — the Data stage of the master map, where CDC is the continuous ingestion mechanism.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/data-versioning-llmops-dvc-lakefs-reproducible-golden-dataset/">Data versioning with DVC and lakeFS&lt;/a> — versioning the corpus that Debezium feeds incrementally.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/gpu-observability-llm-inference-twelve-dcgm-vllm-metrics/">GPU observability with DCGM and LLM&lt;/a> — monitoring the cluster where the Debezium consumer runs alongside the inference stack.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="references">References&lt;/h2>
&lt;ol>
&lt;li>Debezium Documentation — PostgreSQL Connector. &lt;a href="https://debezium.io/documentation/reference/stable/connectors/postgresql.html">debezium.io/documentation/reference/stable/connectors/postgresql.html&lt;/a>&lt;/li>
&lt;li>PostgreSQL Documentation — Logical Replication. &lt;a href="https://www.postgresql.org/docs/current/logical-replication.html">postgresql.org/docs/current/logical-replication.html&lt;/a>&lt;/li>
&lt;li>PostgreSQL Documentation — Write-Ahead Logging. &lt;a href="https://www.postgresql.org/docs/current/wal-intro.html">postgresql.org/docs/current/wal-intro.html&lt;/a>&lt;/li>
&lt;li>PostgreSQL Documentation — Replication Slots. &lt;a href="https://www.postgresql.org/docs/current/logicaldecoding-explanation.html">postgresql.org/docs/current/logicaldecoding-explanation.html&lt;/a>&lt;/li>
&lt;li>Confluent — Kafka Performance Benchmarks (2023). &lt;a href="https://www.confluent.io/blog/kafka-fastest-messaging-system/">confluent.io/blog/kafka-fastest-messaging-system&lt;/a>&lt;/li>
&lt;li>Gunnar Morling — Outbox Pattern. &lt;a href="https://www.morling.dev/blog/sending-messages-as-part-of-database-transactions/">morling.dev/blog/sending-messages-as-part-of-database-transactions&lt;/a>&lt;/li>
&lt;li>Debezium — SMT documentation. &lt;a href="https://debezium.io/documentation/reference/stable/transformations/">debezium.io/documentation/reference/stable/transformations&lt;/a>&lt;/li>
&lt;li>Qdrant Documentation — Filtering. &lt;a href="https://qdrant.tech/documentation/concepts/filtering/">qdrant.tech/documentation/concepts/filtering&lt;/a>&lt;/li>
&lt;/ol></description></item><item><title>Incident response runbooks for LLM inference: every alert to a concrete action with Kafka and Keep</title><link>https://blog.lo0.es/en/posts/incident-response-runbooks-llm-inference-kafka-keep/</link><pubDate>Tue, 02 Jun 2026 04:30:00 +0200</pubDate><guid>https://blog.lo0.es/en/posts/incident-response-runbooks-llm-inference-kafka-keep/</guid><description>&lt;blockquote>
&lt;p>This post closes the observability trilogy opened by &lt;a href="https://blog.lo0.es/en/posts/gpu-observability-llm-inference-twelve-dcgm-vllm-metrics/">GPU observability for LLM inference&lt;/a> (which metrics) and &lt;a href="https://blog.lo0.es/en/posts/anatomy-dcgm-vllm-metrics-analogies-documented-anomalies/">Anatomy of the twelve DCGM and five vLLM metrics&lt;/a> (which documented anomaly per metric). Here each anomaly gets its concrete action and is fitted into the incident management machinery that compliance demands.&lt;/p>
&lt;/blockquote>
&lt;h2 id="tldr">TL;DR&lt;/h2>
&lt;p>The &lt;a href="https://blog.lo0.es/en/posts/gpu-observability-llm-inference-twelve-dcgm-vllm-metrics/">GPU observability&lt;/a> alerts are useless without a codified procedure for each one; the operator who interprets them by hand every time is operating on intuition. The right combination has &lt;strong>three indispensable pieces&lt;/strong>. (1) &lt;strong>Runbook catalogue&lt;/strong>: for each of the six critical alerts (&lt;code>GpuHbmNearOom&lt;/code>, &lt;code>GpuThermalOrPowerThrottle&lt;/code>, &lt;code>GpuXidErrorDetected&lt;/code>, &lt;code>GpuEccDoubleBit&lt;/code>, &lt;code>VllmKvCachePoolNearFull&lt;/code>, &lt;code>VllmTtftP95OutOfSlo&lt;/code>), a severity, an immediate mitigation, the evidence to capture &lt;strong>before&lt;/strong> remediating, a resolution action, a closure criterion and a postmortem trigger. (2) &lt;strong>Reproducible pipeline&lt;/strong>: Prometheus + DCGM → Alertmanager → &lt;strong>Kafka as event bus&lt;/strong> (topics &lt;code>gpu.alerts.enriched&lt;/code>, &lt;code>incidents.lifecycle&lt;/code>, &lt;code>audit.actions&lt;/code> with WORM retention) → &lt;strong>Keep as workflow engine&lt;/strong> (declarative YAML workflows versioned in git) → Kubernetes job / script / ChatOps executors. (3) &lt;strong>Formal fit into incident management&lt;/strong> under the regulatory corpus: &lt;strong>ISO/IEC 27035&lt;/strong> phases &lt;code>identify → report → assess → respond → learn&lt;/code>; &lt;strong>ENS&lt;/strong> controls &lt;code>op.exp.7&lt;/code> (incident management), &lt;code>op.exp.8&lt;/code> (activity logging), &lt;code>op.exp.10&lt;/code> (notification to users); &lt;strong>NIS2&lt;/strong> art. 23 with an early warning at &lt;strong>24 h&lt;/strong>, a formal notification at &lt;strong>72 h&lt;/strong> and a final report at &lt;strong>1 month&lt;/strong>; &lt;strong>EU AI Act&lt;/strong> art. 73 for a serious incident on a high-risk system, deadlines of &lt;strong>2 to 15 days&lt;/strong> depending on severity; &lt;strong>ISO/IEC 42001&lt;/strong> clause 10 (continual improvement of the AIMS). The action taxonomy is &lt;strong>immediate mitigation&lt;/strong> (drain, throttle, scale-down: contains the damage in seconds) → &lt;strong>diagnosis&lt;/strong> (evidence capture with &lt;code>nvidia-smi -q&lt;/code>, &lt;code>dmesg&lt;/code>, a vLLM &lt;code>/metrics&lt;/code> snapshot, the related OTel trace; without this the postmortem is not defensible) → &lt;strong>resolution&lt;/strong> (restart, reset, RMA, rollback) → &lt;strong>postmortem&lt;/strong> (5-whys RCA, prevention plan, runbook update). Kafka contributes the &lt;strong>immutable audit trail&lt;/strong> that ENS and the EU AI Act demand: every action executed by Keep or by a human is published as an event on &lt;code>audit.actions&lt;/code> with timestamp, actor, decision and evidence, retained WORM for at least 6 months. Keep contributes &lt;strong>workflows as code&lt;/strong>: this post includes three complete workflows (XID with drain plus Jira ticket, ECC DBE with immediate paging and node blocking in the scheduler, automatic canary rollback on TTFT P95 out of SLO). Four anti-patterns close the material: alerts without a runbook (most of them), a runbook without prior evidence capture (it perpetuates the incident because the root cause is lost), escalation by seniority rota instead of severity (a junior operator handling an ECC DBE), and the absence of a human gate for destructive actions (Keep running &lt;code>nvidia-smi --gpu-reset&lt;/code> without confirmation). Applicable to a generic 4×H100 SXM cluster with Kafka and Keep already deployed.&lt;/p>
&lt;h2 id="you-are-here-observe--deploy-incident-response-closes-the-loop">You are here: OBSERVE → DEPLOY (incident response closes the loop)&lt;/h2>
&lt;div class="diagram" style="max-width:780px;margin:1rem auto;">
&lt;svg viewBox="0 0 780 90" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="incident response: Observe-Deploy loop">
&lt;style>.box{stroke:#444;stroke-width:1.4;rx:6}.active{fill:#c9a8e9;stroke-width:3}.semiactive{fill:#cfead0;stroke-width:2}.idle{fill:#f4f4f4}.lbl{font:600 12px sans-serif;fill:#222}.arr{stroke:#666;stroke-width:1.4;fill:none;marker-end:url(#rbm)}.cyc{stroke:#888;stroke-width:1.2;fill:none;stroke-dasharray:4 2;marker-end:url(#rbm)}.loop{stroke:#c33;stroke-width:1.8;fill:none;stroke-dasharray:5 3;marker-end:url(#rbmc)}&lt;/style>
&lt;defs>&lt;marker id="rbm" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto">&lt;path d="M0,0 L10,5 L0,10 z" fill="#666"/>&lt;/marker>&lt;marker id="rbmc" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto">&lt;path d="M0,0 L10,5 L0,10 z" fill="#c33"/>&lt;/marker>&lt;/defs>
&lt;text x="390" y="20" text-anchor="middle" class="lbl">Incident response: closes the loop from OBSERVE to DEPLOY (action)&lt;/text>
&lt;rect x="30" y="35" width="110" height="35" class="box idle"/>&lt;text x="85" y="58" text-anchor="middle" class="lbl">1 · Data&lt;/text>
&lt;rect x="155" y="35" width="110" height="35" class="box idle"/>&lt;text x="210" y="58" text-anchor="middle" class="lbl">2 · Tune&lt;/text>
&lt;rect x="280" y="35" width="110" height="35" class="box idle"/>&lt;text x="335" y="58" text-anchor="middle" class="lbl">3 · Eval&lt;/text>
&lt;rect x="405" y="35" width="110" height="35" class="box semiactive"/>&lt;text x="460" y="58" text-anchor="middle" class="lbl">4 · Deploy&lt;/text>
&lt;rect x="530" y="35" width="110" height="35" class="box active"/>&lt;text x="585" y="58" text-anchor="middle" class="lbl">5 · Observe&lt;/text>
&lt;rect x="655" y="35" width="110" height="35" class="box idle"/>&lt;text x="710" y="58" text-anchor="middle" class="lbl">6 · Retrain&lt;/text>
&lt;path class="arr" d="M140,52 L155,52"/>&lt;path class="arr" d="M265,52 L280,52"/>&lt;path class="arr" d="M390,52 L405,52"/>&lt;path class="arr" d="M515,52 L530,52"/>&lt;path class="arr" d="M640,52 L655,52"/>
&lt;path class="loop" d="M530,40 C500,5 480,5 460,40"/>
&lt;/svg>
&lt;/div>
&lt;h2 id="the-analogy-a-nuclear-reactor-control-room">The analogy: a nuclear reactor control room&lt;/h2>
&lt;p>In a nuclear plant control room, the operator on shift &lt;strong>never decides what to do on seeing an alarm&lt;/strong>. The decision is pre-made and codified in a written procedure (SOP) covering every alarm on the panel: if X sounds, open book X, read steps 1-N, execute exactly, call the supervisor at step M, escalate to the plant director at step N+3. The reason is strict: critical alarms are rare but catastrophic if handled badly; an operator improvising in an emergency makes worse decisions than one applying a procedure reviewed by experts and validated by simulation.&lt;/p>
&lt;p>The reactor does not expect the operator to be a genius. It expects them to know the procedures to the letter and the operations management system to hand them the right procedure at the right moment. If the procedures are not written, not versioned, or not integrated with the alarms that fire them, the control room is operating on intuition. The difference between the two operations, procedural versus intuitive, is the difference between a plant that runs 30 years without incidents and one that ends up on a blacklist.&lt;/p>
&lt;p>Incident response on an LLM inference cluster works identically. The DCGM and vLLM alerts listed in the previous posts are the panel alarms. Each one needs its written SOP, versioned, integrated with the alert that fires it and reviewed after every incident. Without that codification, the operator on shift improvises in the middle of an ECC DBE failure at 4 in the morning; with it, they execute the nine steps of runbook 12 and the incident closes in 20 minutes.&lt;/p>
&lt;h2 id="the-incident-pipeline-architecture">The incident pipeline architecture&lt;/h2>
&lt;div class="diagram" style="max-width:840px;margin:1.5rem auto;">
&lt;svg viewBox="0 0 840 320" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="incident response pipeline">
&lt;style>.b{stroke:#333;stroke-width:1.4;rx:6}.src{fill:#dfe9f5;stroke:#356}.am{fill:#eef0d0;stroke:#7a3}.k{fill:#f4e3cf;stroke:#a63}.kp{fill:#ead8f5;stroke:#634}.ex{fill:#d8eecf;stroke:#373}.au{fill:#f6e2e2;stroke:#a33}.title{font:600 13px sans-serif;fill:#222}.h{font:700 12px sans-serif;fill:#222}.l{font:11px sans-serif;fill:#222}.n{font:italic 10px sans-serif;fill:#444}.arr{stroke:#666;stroke-width:1.4;fill:none;marker-end:url(#pim)}.dbl{stroke:#666;stroke-width:1.4;fill:none;stroke-dasharray:4 2;marker-end:url(#pim)}&lt;/style>
&lt;defs>&lt;marker id="pim" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto">&lt;path d="M0,0 L10,5 L0,10 z" fill="#666"/>&lt;/marker>&lt;/defs>
&lt;text x="420" y="20" text-anchor="middle" class="title">Pipeline: Prometheus → Alertmanager → Kafka → Keep → Executors · WORM audit in parallel&lt;/text>
&lt;rect x="20" y="45" width="140" height="60" class="b src"/>&lt;text x="90" y="65" text-anchor="middle" class="h">Prometheus&lt;/text>&lt;text x="90" y="82" text-anchor="middle" class="l">DCGM + vLLM&lt;/text>&lt;text x="90" y="98" text-anchor="middle" class="n">scrape 15s&lt;/text>
&lt;rect x="190" y="45" width="140" height="60" class="b am"/>&lt;text x="260" y="65" text-anchor="middle" class="h">Alertmanager&lt;/text>&lt;text x="260" y="82" text-anchor="middle" class="l">PrometheusRule&lt;/text>&lt;text x="260" y="98" text-anchor="middle" class="n">webhook → kafka&lt;/text>
&lt;rect x="360" y="45" width="160" height="60" class="b k"/>&lt;text x="440" y="65" text-anchor="middle" class="h">Kafka&lt;/text>&lt;text x="440" y="82" text-anchor="middle" class="l">gpu.alerts.enriched&lt;/text>&lt;text x="440" y="98" text-anchor="middle" class="n">incidents.lifecycle&lt;/text>
&lt;rect x="550" y="45" width="140" height="60" class="b kp"/>&lt;text x="620" y="65" text-anchor="middle" class="h">Keep&lt;/text>&lt;text x="620" y="82" text-anchor="middle" class="l">YAML workflows&lt;/text>&lt;text x="620" y="98" text-anchor="middle" class="n">git-versioned&lt;/text>
&lt;rect x="720" y="45" width="100" height="60" class="b ex"/>&lt;text x="770" y="65" text-anchor="middle" class="h">Executors&lt;/text>&lt;text x="770" y="82" text-anchor="middle" class="l">kubectl · API&lt;/text>&lt;text x="770" y="98" text-anchor="middle" class="n">ChatOps&lt;/text>
&lt;path class="arr" d="M160,75 L190,75"/>
&lt;path class="arr" d="M330,75 L360,75"/>
&lt;path class="arr" d="M520,75 L550,75"/>
&lt;path class="arr" d="M690,75 L720,75"/>
&lt;rect x="360" y="160" width="160" height="60" class="b au"/>&lt;text x="440" y="180" text-anchor="middle" class="h">audit.actions&lt;/text>&lt;text x="440" y="197" text-anchor="middle" class="l">WORM topic&lt;/text>&lt;text x="440" y="213" text-anchor="middle" class="n">retention 6 months+&lt;/text>
&lt;path class="dbl" d="M620,105 L520,160"/>
&lt;path class="dbl" d="M770,105 L520,168"/>
&lt;text x="420" y="252" text-anchor="middle" class="n">Every Keep or human action is published to audit.actions: WORM required by ENS op.exp.8 + EU AI Act art. 12.&lt;/text>
&lt;rect x="20" y="240" width="220" height="60" class="b kp"/>&lt;text x="130" y="260" text-anchor="middle" class="h">Compliance consumers&lt;/text>&lt;text x="130" y="277" text-anchor="middle" class="l">DPO · ENS audit · NIS2 reporting&lt;/text>&lt;text x="130" y="293" text-anchor="middle" class="n">read audit.actions read-only&lt;/text>
&lt;path class="arr" d="M360,180 L240,260"/>
&lt;rect x="600" y="240" width="220" height="60" class="b ex"/>&lt;text x="710" y="260" text-anchor="middle" class="h">Postmortem tooling&lt;/text>&lt;text x="710" y="277" text-anchor="middle" class="l">Jira · MLflow · Langfuse&lt;/text>&lt;text x="710" y="293" text-anchor="middle" class="n">enriched with timeline&lt;/text>
&lt;path class="arr" d="M520,180 L600,260"/>
&lt;/svg>
&lt;/div>
&lt;p>&lt;strong>Prometheus + DCGM.&lt;/strong> Collects the metrics described in the two previous posts. PrometheusRules define the six critical alerts with &lt;code>for: &amp;lt;duration&amp;gt;&lt;/code> to avoid noise.&lt;/p>
&lt;p>&lt;strong>Alertmanager.&lt;/strong> Receives raw alerts; deduplicates, groups by labels (&lt;code>{cluster, node, gpu, model}&lt;/code>), routes. Instead of sending straight to PagerDuty or Slack, it &lt;strong>sends to Kafka&lt;/strong> via a webhook receiver. That turns the alert into a bus event that multiple consumers process (Keep for action, the audit topic for compliance, dashboards for visualisation).&lt;/p>
&lt;p>&lt;strong>Kafka as event bus.&lt;/strong> Three canonical topics:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>&lt;code>gpu.alerts.enriched&lt;/code>&lt;/strong> — alerts with added context (tenant, model, version, namespace owner, effective severity). Retention: 7 days, replication factor 3.&lt;/li>
&lt;li>&lt;strong>&lt;code>incidents.lifecycle&lt;/code>&lt;/strong> — incident cycle events: &lt;code>incident.opened&lt;/code>, &lt;code>incident.acknowledged&lt;/code>, &lt;code>action.proposed&lt;/code>, &lt;code>action.executed&lt;/code>, &lt;code>incident.escalated&lt;/code>, &lt;code>incident.resolved&lt;/code>, &lt;code>postmortem.attached&lt;/code>. Retention: 90 days.&lt;/li>
&lt;li>&lt;strong>&lt;code>audit.actions&lt;/code>&lt;/strong> — an immutable record of every action executed (by Keep automatically or by a human confirming). Retention: &lt;strong>6 months minimum with compaction off plus tiered storage&lt;/strong>, WORM storage. This is the topic ENS &lt;code>op.exp.8&lt;/code>, EU AI Act art. 12 and NIS2 require you to keep.&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Keep as workflow engine.&lt;/strong> Consumes from &lt;code>gpu.alerts.enriched&lt;/code>, fires YAML workflows versioned in git, executes actions (HTTP calls, kubectl jobs, Slack messages, Jira tickets) and publishes the result to &lt;code>incidents.lifecycle&lt;/code> plus &lt;code>audit.actions&lt;/code>. Choosing Keep over Alertmanager alone (or over PagerDuty alone) is deliberate: Keep separates &lt;strong>runbook declaration&lt;/strong> (readable, reviewable YAML) from &lt;strong>notification delivery&lt;/strong> (PagerDuty). The runbook is versioned code; notifications are operational details.&lt;/p>
&lt;p>&lt;strong>Executors.&lt;/strong> What actually moves the cluster:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Kubernetes jobs&lt;/strong>: &lt;code>kubectl drain&lt;/code>, &lt;code>kubectl cordon&lt;/code>, &lt;code>kubectl rollout undo&lt;/code>.&lt;/li>
&lt;li>&lt;strong>NVIDIA API&lt;/strong>: &lt;code>nvidia-smi --gpu-reset&lt;/code>, &lt;code>dcgmi diag -r &amp;lt;level&amp;gt;&lt;/code>.&lt;/li>
&lt;li>&lt;strong>ChatOps&lt;/strong>: human confirmations through Slack interactive messages before a destructive action runs.&lt;/li>
&lt;li>&lt;strong>External tooling&lt;/strong>: Jira ticket, PagerDuty notification, CMDB call.&lt;/li>
&lt;/ul>
&lt;h2 id="the-six-critical-alerts-and-their-runbooks">The six critical alerts and their runbooks&lt;/h2>
&lt;p>For each alert: severity, immediate mitigation (seconds), evidence to capture &lt;strong>before remediating&lt;/strong>, resolution action, closure criteria, postmortem trigger.&lt;/p>
&lt;h3 id="rb-01--gpuhbmnearoom--hbm--92--sustained">RB-01 · &lt;code>GpuHbmNearOom&lt;/code> — HBM &amp;gt; 92 % sustained&lt;/h3>
&lt;p>&lt;strong>Severity&lt;/strong>: WARNING. Risk of OOM on the next PagedAttention allocation.&lt;/p>
&lt;p>&lt;strong>Immediate mitigation.&lt;/strong> Reduce admission temporarily by lowering &lt;code>max_num_seqs&lt;/code> on the affected engine via hot reload (if the engine supports it) or a staggered restart of replicas. Trigger an additional scale-out via KEDA if there are free GPU nodes. There is no need to drain the node.&lt;/p>
&lt;p>&lt;strong>Evidence to capture.&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">nvidia-smi --query-gpu&lt;span class="o">=&lt;/span>index,memory.used,memory.free,memory.total --format&lt;span class="o">=&lt;/span>csv
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">nvidia-smi -q -d ROW_REMAPPER &lt;span class="p">|&lt;/span> grep -i pending
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">curl http://vllm-pod:8000/metrics &lt;span class="p">|&lt;/span> grep -E &lt;span class="s2">&amp;#34;gpu_cache_usage|num_requests&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">kubectl logs &amp;lt;pod&amp;gt; --tail&lt;span class="o">=&lt;/span>&lt;span class="m">200&lt;/span> &lt;span class="p">|&lt;/span> grep -i &lt;span class="s2">&amp;#34;preempt\|swap&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Save the snapshot to &lt;code>audit.actions&lt;/code> with a timestamp and an &lt;code>incident_id&lt;/code>.&lt;/p>
&lt;p>&lt;strong>Resolution.&lt;/strong> If the cause is a traffic spike: let the autoscaler scale to a stable regime, monitor for 30 min. If the cause is a model regression (canary v2 consumes more KV cache than v1): roll the canary back (see RB-06). If it is a leak (the metric grows without traffic growing): restart the pod with a heap dump capture.&lt;/p>
&lt;p>&lt;strong>Closure.&lt;/strong> &lt;code>gpu_cache_usage_perc &amp;lt; 80 %&lt;/code> sustained for 15 min AND &lt;code>num_requests_waiting == 0&lt;/code>.&lt;/p>
&lt;p>&lt;strong>Postmortem.&lt;/strong> Not mandatory unless the incident lasted &amp;gt; 30 min or had SLO impact.&lt;/p>
&lt;h3 id="rb-02--gputhermalorpowerthrottle--bit--0-and-not-idle-in-clock_throttle_reasons">RB-02 · &lt;code>GpuThermalOrPowerThrottle&lt;/code> — bit ≠ 0 and not Idle in CLOCK_THROTTLE_REASONS&lt;/h3>
&lt;p>&lt;strong>Severity&lt;/strong>: WARNING (thermal) or CRITICAL (sustained HW Power Brake, PDU risk).&lt;/p>
&lt;p>&lt;strong>Immediate mitigation.&lt;/strong> Identify the bit (decode the bitmap). If it is &lt;strong>&lt;code>0x40 HW_THERMAL&lt;/code>&lt;/strong> or &lt;strong>&lt;code>0x20 SW_THERMAL&lt;/code>&lt;/strong>: drain the workload from the node to other replicas if the temperature does not drop within 2 min, and stop new pods landing on that node (&lt;code>kubectl cordon&lt;/code>). If it is &lt;strong>&lt;code>0x80 HW_POWER_BRAKE&lt;/code>&lt;/strong>: alert DC infrastructure immediately (likely an over-committed PDU, the Dell KB 000220508 / Lenovo HT514380 case) and lower the TDP of the rack&amp;rsquo;s GPUs via &lt;code>nvidia-smi -pl&lt;/code> to a lower value to relieve load on the breaker.&lt;/p>
&lt;p>&lt;strong>Evidence.&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">nvidia-smi --query-gpu&lt;span class="o">=&lt;/span>index,temperature.gpu,temperature.memory,power.draw,clocks_throttle_reasons.active --format&lt;span class="o">=&lt;/span>csv
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ipmitool sdr &lt;span class="p">|&lt;/span> grep -i &lt;span class="s2">&amp;#34;fan\|temp\|inlet&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># PDU data if they are instrumented (modbus / SNMP)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>Resolution.&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Thermal&lt;/strong>: review rack airflow, check the rear-door HX, T_inlet, DGX fans. An infra issue, not an engine one.&lt;/li>
&lt;li>&lt;strong>Power Brake&lt;/strong>: review the sizing of the PDU branch, the breaker, the 415 VAC distribution. Likely a redistribution of load to another branch or a temporary TDP cap.&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Closure.&lt;/strong> &lt;code>CLOCK_THROTTLE_REASONS == 0x1&lt;/code> (Idle only) or &lt;code>0x0&lt;/code> for 30 min under normal load.&lt;/p>
&lt;p>&lt;strong>Postmortem.&lt;/strong> Mandatory if it was a HW Power Brake: that implicates the DC electrical infrastructure.&lt;/p>
&lt;h3 id="rb-03--gpuxiderrordetected--increasedcgm_fi_dev_xid_errors5m--0">RB-03 · &lt;code>GpuXidErrorDetected&lt;/code> — &lt;code>increase(DCGM_FI_DEV_XID_ERRORS[5m]) &amp;gt; 0&lt;/code>&lt;/h3>
&lt;p>&lt;strong>Severity&lt;/strong>: CRITICAL.&lt;/p>
&lt;p>&lt;strong>Immediate mitigation.&lt;/strong> &lt;code>kubectl cordon&lt;/code> the node (no more new pods). If the XID is 31/48/79/94/95 (hardware or cascade): drain the node&amp;rsquo;s existing pods. If the XID is 13/43 (possibly software): keep the pods but block new ones, capture the trace and the active workload.&lt;/p>
&lt;p>&lt;strong>Evidence.&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># The specific XID from dmesg&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">dmesg &lt;span class="p">|&lt;/span> grep -i xid &lt;span class="p">|&lt;/span> tail -30
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">nvidia-smi -q -d ERROR
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">nvidia-smi -q -d PCIE
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># State of the retired pages&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">nvidia-smi -q -d ROW_REMAPPER
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Workload that was running&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">kubectl get pods -o wide &lt;span class="p">|&lt;/span> grep &amp;lt;node&amp;gt;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">kubectl logs &amp;lt;pod&amp;gt; --previous --tail&lt;span class="o">=&lt;/span>&lt;span class="m">500&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>Resolution.&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>&lt;strong>XID 13/43&lt;/strong> (software exception / channel verif): if it recurs only with one specific model, it is a workload bug; raise an issue with the model team. If it is transient, restarting the pod is enough.&lt;/li>
&lt;li>&lt;strong>XID 31&lt;/strong> (MMU fault): usually a cascade from a previous XID 48. Reset the GPU (&lt;code>nvidia-smi --gpu-reset -i &amp;lt;index&amp;gt;&lt;/code>) or reboot the node if the reset does not resolve it.&lt;/li>
&lt;li>&lt;strong>XID 48 / 95&lt;/strong> (DBE / uncontained ECC): see RB-04. The node goes into quarantine.&lt;/li>
&lt;li>&lt;strong>XID 79&lt;/strong> (fallen off the bus): reboot the node. If it recurs after the reboot, open an RMA for the GPU. ByteDance reports 43 % co-occurrence with PCIe errors, so check the slot and the cable too.&lt;/li>
&lt;li>&lt;strong>XID 94 / 145 / 149&lt;/strong>: catalogued in NVIDIA&amp;rsquo;s Xid Catalog with a specific procedure.&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Closure.&lt;/strong> Node smoke test passed (&lt;code>dcgmi diag -r 3&lt;/code>), 24 h with no new XIDs, back into the pool.&lt;/p>
&lt;p>&lt;strong>Postmortem.&lt;/strong> &lt;strong>Mandatory&lt;/strong>. Include the specific XID, the distribution of XIDs across the cluster, an updated MTBE.&lt;/p>
&lt;h3 id="rb-04--gpueccdoublebit--dcgm_fi_dev_ecc_dbe_vol_total--0">RB-04 · &lt;code>GpuEccDoubleBit&lt;/code> — &lt;code>DCGM_FI_DEV_ECC_DBE_VOL_TOTAL &amp;gt; 0&lt;/code>&lt;/h3>
&lt;p>&lt;strong>Severity&lt;/strong>: CRITICAL, data corruption in progress.&lt;/p>
&lt;p>&lt;strong>Immediate mitigation.&lt;/strong> &lt;strong>Drain the node immediately without waiting for further evidence.&lt;/strong> Page (PagerDuty / OpsGenie) the primary ON-CALL. Mark the node &lt;code>unschedulable&lt;/code> and &lt;code>failed&lt;/code>. XID 48 has a &lt;strong>100 % probability of killing the running job&lt;/strong> according to the &lt;em>Story of Two GPUs&lt;/em> dataset; any inference already in flight is compromised.&lt;/p>
&lt;p>&lt;strong>Evidence (in parallel with the mitigation).&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">nvidia-smi -q -d ECC
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">nvidia-smi -q -d ROW_REMAPPER &lt;span class="c1"># Pending: Yes expected&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">dmesg &lt;span class="p">|&lt;/span> grep -E &lt;span class="s2">&amp;#34;Xid.*48|DBE|double-bit&amp;#34;&lt;/span> &lt;span class="p">|&lt;/span> tail -50
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Full capture of the GPU state&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">dcgmi diag -r &lt;span class="m">4&lt;/span> -i &amp;lt;gpu_index&amp;gt;
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>Resolution.&lt;/strong> Full GPU reset (&lt;code>nvidia-smi --gpu-reset&lt;/code>) or a node reboot if the reset does not complete. The reset activates the row remap. After the reboot:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">nvidia-smi -q -d ROW_REMAPPER &lt;span class="c1"># Pending: No expected&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">nvidia-smi -q -d ECC &lt;span class="c1"># volatile counters at 0&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>If &lt;code>RETIRED_DBE &amp;gt; 8&lt;/code> pages after the remap: schedule a &lt;strong>GPU replacement&lt;/strong> in the next window, because silicon degradation is progressive. The published real case documents &lt;em>~19 hours of downtime&lt;/em> as typical.&lt;/p>
&lt;p>&lt;strong>Closure.&lt;/strong> Node back in the pool after 48 h with no new DBEs.&lt;/p>
&lt;p>&lt;strong>Postmortem.&lt;/strong> &lt;strong>Mandatory&lt;/strong>. If the incident affected a request carrying personal or classified data, evaluate notification to the DPO under GDPR art. 33 (it is not necessarily a breach, but it has to be assessed).&lt;/p>
&lt;h3 id="rb-05--vllmkvcachepoolnearfull--gpu_cache_usage_perc--95--sustained-3-min">RB-05 · &lt;code>VllmKvCachePoolNearFull&lt;/code> — &lt;code>gpu_cache_usage_perc &amp;gt; 95 %&lt;/code> sustained 3 min&lt;/h3>
&lt;p>&lt;strong>Severity&lt;/strong>: WARNING (risk of preempt-on-OOM, not of a real OOM).&lt;/p>
&lt;p>&lt;strong>Immediate mitigation.&lt;/strong> Activate autoscaler scale-out by lowering the KEDA threshold temporarily (from 0.85 to 0.75) for 30 min. In &lt;code>recompute&lt;/code> mode, preempts raise TTFT but do not break requests; acceptable in the short term. In &lt;code>swap&lt;/code> mode latency goes through the roof, so it is better to cut new traffic (return 503 from the &lt;a href="https://blog.lo0.es/en/posts/llm-inference-router-l7-switchboard/">router&lt;/a>) for 5 min.&lt;/p>
&lt;p>&lt;strong>Evidence.&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">curl http://vllm-pod:8000/metrics &lt;span class="p">|&lt;/span> grep -E &lt;span class="s2">&amp;#34;gpu_cache|num_requests|num_preemptions&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">kubectl get hpa vllm-llama70b
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">kubectl logs &amp;lt;pod&amp;gt; --tail&lt;span class="o">=&lt;/span>&lt;span class="m">200&lt;/span> &lt;span class="p">|&lt;/span> grep -i preempt
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>Resolution.&lt;/strong> If it recurs regularly: revisit capacity planning, possibly lowering &lt;code>max_num_seqs&lt;/code> or raising the stable replica count. See &lt;a href="https://blog.lo0.es/en/posts/capacity-planning-on-premise-llm-inference/">Capacity planning&lt;/a>.&lt;/p>
&lt;p>&lt;strong>Closure.&lt;/strong> Pool &amp;lt; 85 % sustained 30 min, no preempts in the last 15 min.&lt;/p>
&lt;p>&lt;strong>Postmortem.&lt;/strong> Not mandatory unless it recurs &amp;gt; 3 times / week.&lt;/p>
&lt;h3 id="rb-06--vllmttftp95outofslo--ttft-p95--15-s-for-5-min">RB-06 · &lt;code>VllmTtftP95OutOfSlo&lt;/code> — TTFT P95 &amp;gt; 1.5 s for 5 min&lt;/h3>
&lt;p>&lt;strong>Severity&lt;/strong>: CRITICAL (contractual SLO violation).&lt;/p>
&lt;p>&lt;strong>Immediate mitigation.&lt;/strong> Quick diagnosis of the regime (in order of likelihood):&lt;/p>
&lt;ol>
&lt;li>If a v2 canary is active and the ratio &lt;code>ttft_p95(v2)/ttft_p95(v1) &amp;gt; 1.30&lt;/code>: &lt;strong>automatic rollback&lt;/strong> of the canary via Argo Rollouts (&lt;code>argo rollouts abort vllm-llama70b&lt;/code>).&lt;/li>
&lt;li>If &lt;code>num_requests_waiting &amp;gt; 5&lt;/code>: scale out via KEDA.&lt;/li>
&lt;li>If &lt;code>DRAM_ACTIVE &amp;gt; 90 %&lt;/code> plus &lt;code>gpu_cache_usage_perc &amp;gt; 90 %&lt;/code>: HBM bottleneck, reach for the quantisation lever or a context reduction.&lt;/li>
&lt;li>If &lt;code>CLOCK_THROTTLE_REASONS != 0&lt;/code>: see RB-02.&lt;/li>
&lt;/ol>
&lt;p>&lt;strong>Evidence.&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Histogram snapshot&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">curl http://vllm-pod:8000/metrics &lt;span class="p">|&lt;/span> grep time_to_first_token
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Breakdown by version if a canary is running&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># DCGM state at that moment&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">curl http://dcgm-exporter:9400/metrics &lt;span class="p">|&lt;/span> grep -E &lt;span class="s2">&amp;#34;PIPE_TENSOR|DRAM_ACTIVE|THROTTLE&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Active traffic&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">kubectl top pods -n inference
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;strong>Resolution.&lt;/strong> Depends on the diagnosis. Typical cases:&lt;/p>
&lt;ul>
&lt;li>Canary regression → full rollback (see &lt;a href="https://blog.lo0.es/en/posts/canary-blue-green-shadow-llm-models/">Canary&lt;/a>).&lt;/li>
&lt;li>Capacity saturation → scale replicas or accept a temporary 503 with &lt;code>Retry-After&lt;/code>.&lt;/li>
&lt;li>Prefill bound → enable or calibrate chunked prefill or disaggregated serving (see &lt;a href="https://blog.lo0.es/en/posts/disaggregated-serving-prefill-decode-specialised-pods/">Disaggregated serving&lt;/a>).&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Closure.&lt;/strong> TTFT P95 inside SLO sustained 30 min.&lt;/p>
&lt;p>&lt;strong>Postmortem.&lt;/strong> &lt;strong>Mandatory&lt;/strong>. Document the root cause and the lever applied; update the runbook.&lt;/p>
&lt;h2 id="keep-yaml-workflows--three-complete-examples">Keep YAML workflows — three complete examples&lt;/h2>
&lt;p>Runbooks are only useful if they are &lt;strong>codified&lt;/strong> in the workflow engine. Keep lets you declare them in YAML versioned in git.&lt;/p>
&lt;h3 id="workflow-1--xid-detectedyaml">Workflow 1 — &lt;code>xid-detected.yaml&lt;/code>&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-yaml" data-lang="yaml">&lt;span class="line">&lt;span class="cl">&lt;span class="nt">workflow&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">id&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">xid-detected-drain&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;XID error detected — cordon node and capture evidence&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">description&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;RB-03 implementation&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">triggers&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">type&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">alert&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">filters&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">key&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">alertname&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">value&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">GpuXidErrorDetected&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">steps&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">capture-evidence&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">provider&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">type&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">bash&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">with&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">command&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">|&lt;/span>&lt;span class="sd">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> set -e
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> NODE=&amp;#34;{{ alert.labels.node }}&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> GPU=&amp;#34;{{ alert.labels.gpu }}&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> INC_ID=&amp;#34;{{ alert.fingerprint }}&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> mkdir -p /var/evidence/$INC_ID
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> kubectl debug node/$NODE -it --image=nvcr.io/nvidia/cuda:12.4.0-base-ubuntu22.04 -- \
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> bash -c &amp;#34;nvidia-smi -q -d ERROR,PCIE,ROW_REMAPPER &amp;gt; /host/var/evidence/$INC_ID/smi.txt&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> kubectl describe node $NODE &amp;gt; /var/evidence/$INC_ID/node.txt&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">cordon-node&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">provider&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">type&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">kubernetes&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">with&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">action&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">cordon&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ alert.labels.node }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">if&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ alert.labels.severity == &amp;#39;critical&amp;#39; }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">actions&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">open-jira-ticket&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">provider&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">type&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">jira&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">config&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ providers.jira-prod }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">with&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">project&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">GPUOPS&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">issuetype&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">Incident&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">summary&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;RB-03: XID {{ alert.annotations.xid_code }} on {{ alert.labels.node }}/{{ alert.labels.gpu }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">description&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">|&lt;/span>&lt;span class="sd">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> Severity: {{ alert.labels.severity }}
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> XID: {{ alert.annotations.xid_code }}
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> Evidence: /var/evidence/{{ alert.fingerprint }}
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> Runbook: https://runbooks.example.local/RB-03&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">notify-slack&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">provider&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">type&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">slack&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">config&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ providers.slack-gpu-incidents }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">with&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">message&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">|&lt;/span>&lt;span class="sd">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> :warning: *RB-03 triggered*
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> Node: `{{ alert.labels.node }}` GPU: `{{ alert.labels.gpu }}`
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> XID: `{{ alert.annotations.xid_code }}`
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> &amp;lt;{{ jira.url }}|Jira ticket&amp;gt;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">emit-audit&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">provider&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">type&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">kafka&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">config&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ providers.kafka-audit }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">with&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">topic&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">audit.actions&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">message&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">incident_id&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ alert.fingerprint }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">action&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;cordon_node&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">actor&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;keep-workflow&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">workflow_id&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;xid-detected-drain&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">target&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ alert.labels.node }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">timestamp&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ now }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="workflow-2--ecc-dbeyaml--immediate-paging">Workflow 2 — &lt;code>ecc-dbe.yaml&lt;/code> — immediate paging&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-yaml" data-lang="yaml">&lt;span class="line">&lt;span class="cl">&lt;span class="nt">workflow&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">id&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">ecc-dbe-critical&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;ECC double-bit — page on-call and quarantine node&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">triggers&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">type&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">alert&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">filters&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">key&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">alertname&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">value&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">GpuEccDoubleBit&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">steps&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">cordon-immediately&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">provider&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">type&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">kubernetes&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">with&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">action&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">cordon&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ alert.labels.node }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">drain-workload&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">provider&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">type&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">kubernetes&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">with&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">action&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">drain&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ alert.labels.node }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">options&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">ignore-daemonsets&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kc">true&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">delete-emptydir-data&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kc">true&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">grace-period&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="m">120&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">page-oncall&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">provider&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">type&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">pagerduty&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">config&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ providers.pagerduty-critical }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">with&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">service_key&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ env.PD_SERVICE_KEY }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">severity&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">critical&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">summary&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;RB-04 ECC DBE on {{ alert.labels.node }}/{{ alert.labels.gpu }} — node drained&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">emit-lifecycle&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">provider&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">type&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">kafka&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">config&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ providers.kafka-incidents }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">with&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">topic&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">incidents.lifecycle&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">message&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">incident_id&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ alert.fingerprint }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">event&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">incident.opened&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">severity&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">critical&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">runbook&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">RB-04&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">requires_postmortem&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kc">true&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">notify-dpo&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">provider&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">type&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">email&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">with&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">to&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">dpo@example.local&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">subject&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;ECC DBE on a production GPU — assessment required&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">body&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">|&lt;/span>&lt;span class="sd">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> RB-04 ECC DBE incident detected on {{ alert.labels.node }}.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> Affected model: {{ alert.labels.model }}.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> Please assess whether personal/classified data was processed
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> during the error window and whether GDPR art. 33 notification is needed.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="workflow-3--canary-rollbackyaml--ttft-p95-out-of-slo">Workflow 3 — &lt;code>canary-rollback.yaml&lt;/code> — TTFT P95 out of SLO&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-yaml" data-lang="yaml">&lt;span class="line">&lt;span class="cl">&lt;span class="nt">workflow&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">id&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">canary-rollback-ttft&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;Rollback canary when TTFT P95 ratio v2/v1 &amp;gt; 1.30&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">triggers&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">type&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">alert&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">filters&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">key&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">alertname&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">value&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">VllmTtftP95OutOfSlo&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">key&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">canary_active&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">value&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;true&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">steps&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">check-ratio&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">provider&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">type&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">prometheus&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">config&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ providers.prom-prod }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">with&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">query&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">|&lt;/span>&lt;span class="sd">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> histogram_quantile(0.95, sum by(le)(rate(vllm:time_to_first_token_seconds_bucket{version=&amp;#34;v2&amp;#34;}[5m])))
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> /
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sd"> histogram_quantile(0.95, sum by(le)(rate(vllm:time_to_first_token_seconds_bucket{version=&amp;#34;v1&amp;#34;}[5m])))&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">condition&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">result &amp;gt; 1.30&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">actions&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">argo-rollback&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">provider&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">type&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">kubernetes&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">with&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">action&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">exec&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">command&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="l">kubectl&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="l">argo&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="l">rollouts&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="l">abort&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="s2">&amp;#34;{{ alert.labels.rollout }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- -&lt;span class="kc">n&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="s2">&amp;#34;{{ alert.labels.namespace }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">notify-and-audit&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">provider&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">type&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">kafka&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">config&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ providers.kafka-audit }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">with&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">topic&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">audit.actions&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">message&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">incident_id&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ alert.fingerprint }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">action&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">canary_rollback&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">ratio&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ steps.check-ratio.result }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">actor&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">keep-workflow&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">timestamp&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;{{ now }}&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Each workflow lives in &lt;code>repos/keep-workflows/&lt;/code> versioned in git, reviewed by pull request, validated by CI (&lt;code>keep workflow validate&lt;/code>). The written runbook lives as &lt;code>docs/runbooks/RB-XX.md&lt;/code> linked from the workflow YAML; the two always evolve together.&lt;/p>
&lt;h2 id="the-canonical-kafka-event-schema">The canonical Kafka event schema&lt;/h2>
&lt;p>For the topics to be consumable by compliance, postmortem tooling and dashboards without each consumer having to guess the shape, the schema is fixed with Avro / Protobuf.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-json" data-lang="json">&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;IncidentLifecycleEvent&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;record&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;fields&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">[&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;incident_id&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;string&amp;#34;&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;event&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;enum&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;symbols&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">[&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s2">&amp;#34;incident.opened&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s2">&amp;#34;incident.acknowledged&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s2">&amp;#34;action.proposed&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s2">&amp;#34;action.executed&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s2">&amp;#34;action.failed&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s2">&amp;#34;incident.escalated&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s2">&amp;#34;incident.resolved&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s2">&amp;#34;postmortem.attached&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">]}},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;timestamp&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;string&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;logicalType&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;timestamp-millis&amp;#34;&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;actor&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;string&amp;#34;&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;severity&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;enum&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;symbols&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;low&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s2">&amp;#34;warning&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s2">&amp;#34;critical&amp;#34;&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;runbook&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;null&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s2">&amp;#34;string&amp;#34;&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="nt">&amp;#34;default&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="kc">null&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;alert_name&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;string&amp;#34;&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;labels&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;map&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;values&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;string&amp;#34;&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;annotations&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;map&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;values&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;string&amp;#34;&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;evidence_uri&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;null&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s2">&amp;#34;string&amp;#34;&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="nt">&amp;#34;default&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="kc">null&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;requires_postmortem&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;boolean&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;default&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="kc">false&lt;/span> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">]&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>For &lt;code>audit.actions&lt;/code> (WORM), a separate and stricter schema with non-modifiable fields:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-json" data-lang="json">&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;AuditAction&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;record&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;fields&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">[&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;incident_id&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;string&amp;#34;&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;action&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;string&amp;#34;&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;actor&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;string&amp;#34;&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;actor_type&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;enum&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;symbols&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;human&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s2">&amp;#34;workflow&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s2">&amp;#34;scheduler&amp;#34;&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;workflow_id&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;null&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s2">&amp;#34;string&amp;#34;&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="nt">&amp;#34;default&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="kc">null&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;target&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;string&amp;#34;&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;command&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;null&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s2">&amp;#34;string&amp;#34;&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="nt">&amp;#34;default&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="kc">null&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;result&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;enum&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;symbols&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;success&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s2">&amp;#34;failure&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s2">&amp;#34;partial&amp;#34;&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;timestamp&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;string&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;logicalType&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;timestamp-millis&amp;#34;&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;evidence_uri&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;null&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s2">&amp;#34;string&amp;#34;&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="nt">&amp;#34;default&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="kc">null&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;approver&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nt">&amp;#34;type&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;null&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s2">&amp;#34;string&amp;#34;&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="nt">&amp;#34;default&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="kc">null&lt;/span> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">]&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The topic is configured with &lt;code>cleanup.policy=delete&lt;/code>, &lt;code>retention.ms=15552000000&lt;/code> (6 months) and &lt;code>min.insync.replicas=2&lt;/code> with &lt;code>acks=all&lt;/code> to guarantee durability. For longer retention without the Kafka cost, use &lt;strong>tiered storage&lt;/strong> to Ceph RGW or an S3-compatible backend: new log in the hot tier, old log in the cold tier, transparently to the consumer.&lt;/p>
&lt;h2 id="formal-fit-into-incident-management">Formal fit into incident management&lt;/h2>
&lt;p>Runbooks are not an isolated SRE practice. They fit into four regulatory frameworks that production LLM platforms touch daily.&lt;/p>
&lt;h3 id="isoiec-27035--information-security-incident-management">ISO/IEC 27035 — information security incident management&lt;/h3>
&lt;p>It defines the formal cycle in five phases: &lt;strong>plan &amp;amp; prepare&lt;/strong> → &lt;strong>detect &amp;amp; report&lt;/strong> → &lt;strong>assess &amp;amp; decide&lt;/strong> → &lt;strong>respond&lt;/strong> → &lt;strong>lessons learned&lt;/strong>. Each phase has outputs that must be documented. Translated to the stack:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Plan &amp;amp; prepare&lt;/strong>: runbooks RB-01 to RB-06 plus the Keep workflows are part of the &lt;em>Information Security Incident Management Plan&lt;/em>. Versioned in git, reviewed annually.&lt;/li>
&lt;li>&lt;strong>Detect &amp;amp; report&lt;/strong>: the Prometheus alerts entering Kafka are the materialisation.&lt;/li>
&lt;li>&lt;strong>Assess &amp;amp; decide&lt;/strong>: the severity in &lt;code>gpu.alerts.enriched&lt;/code> plus the Keep workflow logic.&lt;/li>
&lt;li>&lt;strong>Respond&lt;/strong>: execution of the workflow&amp;rsquo;s &lt;code>steps&lt;/code> plus &lt;code>actions&lt;/code>.&lt;/li>
&lt;li>&lt;strong>Lessons learned&lt;/strong>: a mandatory postmortem for the runbooks that flag it; the output documented in the postmortem repo plus the runbook update.&lt;/li>
&lt;/ul>
&lt;h3 id="ens-esquema-nacional-de-seguridad--opexp-controls">ENS (Esquema Nacional de Seguridad) — op.exp controls&lt;/h3>
&lt;ul>
&lt;li>&lt;strong>&lt;code>op.exp.7&lt;/code> Incident management&lt;/strong>: the runbook catalogue plus the Keep / Kafka pipeline materialise the &amp;ldquo;organised and procedural response&amp;rdquo;.&lt;/li>
&lt;li>&lt;strong>&lt;code>op.exp.8&lt;/code> Activity logging&lt;/strong>: the &lt;code>audit.actions&lt;/code> topic with WORM retention of 6 months (minimum for level ALTO).&lt;/li>
&lt;li>&lt;strong>&lt;code>op.exp.9&lt;/code> Incident management logging&lt;/strong>: the &lt;code>incidents.lifecycle&lt;/code> topic with the full cycle of each incident.&lt;/li>
&lt;li>&lt;strong>&lt;code>op.exp.10&lt;/code> Protection of activity logs&lt;/strong>: WORM plus encryption at rest plus access control (compliance consumers read-only).&lt;/li>
&lt;/ul>
&lt;h3 id="nis2--notification-to-the-competent-authority">NIS2 — notification to the competent authority&lt;/h3>
&lt;p>For essential and important entities, art. 23 sets three deadlines from the detection of &lt;em>significant impact&lt;/em>:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>24 hours&lt;/strong>: an early warning to the national CSIRT (INCIBE-CERT in Spain).&lt;/li>
&lt;li>&lt;strong>72 hours&lt;/strong>: a formal notification with an initial assessment.&lt;/li>
&lt;li>&lt;strong>1 month&lt;/strong>: a final report with root cause, impact and corrective measures.&lt;/li>
&lt;/ul>
&lt;p>The data for those reports comes straight out of &lt;code>incidents.lifecycle&lt;/code> plus &lt;code>audit.actions&lt;/code> with a consumer that generates the dossier in the required format. Without the auditable pipeline, the NIS2 deadlines are unreachable.&lt;/p>
&lt;h3 id="eu-ai-act--art-73-serious-incident-reporting">EU AI Act — art. 73 (serious incident reporting)&lt;/h3>
&lt;p>Applicable to high-risk systems. Deadlines:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>2 days&lt;/strong>: for incidents causing death or irreversible harm to people or critical infrastructure.&lt;/li>
&lt;li>&lt;strong>10 days&lt;/strong>: for incidents producing serious disruption of critical infrastructure.&lt;/li>
&lt;li>&lt;strong>15 days&lt;/strong>: for all other &amp;ldquo;serious incidents&amp;rdquo;.&lt;/li>
&lt;/ul>
&lt;p>The definition of &amp;ldquo;serious incident&amp;rdquo; includes systematic model failures, a fundamental rights breach, material or environmental harm. Runbooks must flag which alerts can lead to a serious incident (typically anything affecting the model&amp;rsquo;s output in a high-risk context) and fire a specific legal assessment sub-workflow.&lt;/p>
&lt;h3 id="isoiec-42001--aims-clause-10-continual-improvement">ISO/IEC 42001 — AIMS clause 10 continual improvement&lt;/h3>
&lt;p>The mandatory post-incident postmortem feeds clause 10. Updating the runbook after every incident that reveals a new pattern is the &amp;ldquo;corrective action with verification of effectiveness&amp;rdquo; the standard demands. See &lt;a href="https://blog.lo0.es/en/posts/iso-42001-aims-on-premise-llm-platform/">ISO 42001 AIMS&lt;/a>.&lt;/p>
&lt;h2 id="four-anti-patterns">Four anti-patterns&lt;/h2>
&lt;p>&lt;strong>Anti-pattern 1 — alerts without a runbook.&lt;/strong> The alert fires, the junior operator on call looks at the dashboard, searches Confluence, finds nothing up to date, calls the senior on Slack, waits 20 minutes. In that time the incident has grown. Rule: &lt;strong>no alert goes to production without a published runbook and an approved Keep workflow&lt;/strong>. CI validates that every &lt;code>PrometheusRule&lt;/code> with severity ≥ warning has its corresponding &lt;code>keep workflow&lt;/code>.&lt;/p>
&lt;p>&lt;strong>Anti-pattern 2 — a runbook without prior evidence capture.&lt;/strong> The workflow runs &lt;code>nvidia-smi --gpu-reset&lt;/code> as soon as the XID arrives, losing the state that would have diagnosed the root cause. The next identical XID forces the diagnosis to be redone from scratch. Rule: &lt;strong>&lt;code>steps&lt;/code> before &lt;code>actions&lt;/code>&lt;/strong>; all evidence is captured first, destructive actions come after.&lt;/p>
&lt;p>&lt;strong>Anti-pattern 3 — escalation by seniority rota instead of severity.&lt;/strong> The junior operator on call handles an ECC DBE because &amp;ldquo;it is their turn&amp;rdquo;. They lack the context to understand row remap, retired pages or the data corruption risk. Rule: &lt;strong>page by severity, not by rota&lt;/strong>: RB-04 and RB-03 page the senior primary ON-CALL with automatic escalation to infra/hardware if there is no acknowledgement within 10 min.&lt;/p>
&lt;p>&lt;strong>Anti-pattern 4 — no human gate for destructive actions.&lt;/strong> The workflow runs &lt;code>kubectl drain&lt;/code> automatically on any alert marked CRITICAL. On the first false alarm (a transient that resolved itself in 30 s), Keep drained a production node during peak hour. Rule: &lt;strong>destructive actions (drain, reset, RMA, full rollback) require human confirmation&lt;/strong> via a Slack interactive message, with a configurable timeout. A justified exception: ECC DBE confirmed by &amp;gt; 1 measurement, where the corruption risk outweighs the false alarm risk.&lt;/p>
&lt;h2 id="applied-to-typical-on-premise-hardware">Applied to typical on-premise hardware&lt;/h2>
&lt;p>For a generic cluster of &lt;strong>4 nodes × 4×H100 SXM 80 GB&lt;/strong> with &lt;strong>Kafka and Keep already deployed&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Kafka&lt;/strong>: a 3-broker cluster on non-GPU nodes of the K8s cluster; topics &lt;code>gpu.alerts.enriched&lt;/code>, &lt;code>incidents.lifecycle&lt;/code>, &lt;code>audit.actions&lt;/code> configured with replication factor 3, min.insync.replicas 2. Audit with tiered storage to Ceph RGW for retention &amp;gt; 6 months without a brutal cost.&lt;/li>
&lt;li>&lt;strong>Keep&lt;/strong>: 2 operator replicas plus 1 worker replica in a &lt;code>keep&lt;/code> namespace; connected to Prometheus (read provider), Kafka (read plus write provider), Slack, PagerDuty, Jira, Kubernetes (provider with a dedicated SA holding &lt;code>get/list/patch nodes&lt;/code> and &lt;code>create jobs&lt;/code> permissions).&lt;/li>
&lt;li>&lt;strong>Workflows&lt;/strong>: ~25-40 YAML files in the &lt;code>infra/keep-workflows/&lt;/code> repo, synchronised with the cluster via Flux or Argo CD. Validated by CI (&lt;code>keep workflow validate&lt;/code>) on every PR.&lt;/li>
&lt;li>&lt;strong>Event volume&lt;/strong>: for 16 GPUs in normal operation with debounced alerts, ~50-200 events/day on &lt;code>gpu.alerts.enriched&lt;/code>. In a typical incident, peaks of 500-2,000 events/day.&lt;/li>
&lt;li>&lt;strong>Compliance consumers&lt;/strong>: a python consumer in the &lt;code>compliance&lt;/code> namespace that generates NIS2 / ENS / EU AI Act reports weekly, reading &lt;code>audit.actions&lt;/code> and &lt;code>incidents.lifecycle&lt;/code>.&lt;/li>
&lt;/ul>
&lt;h2 id="what-we-have-not-covered-upcoming-posts">What we have not covered (upcoming posts)&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Postmortem playbooks&lt;/strong> — the mechanics of RCA with 5-whys, Ishikawa adapted to LLMs, integration with MLflow tracking for re-training if the postmortem produces an enriched dataset.&lt;/li>
&lt;li>&lt;strong>Chaos engineering for LLMs&lt;/strong> — controlled injection of XID errors, simulated ECC, artificial HBM latency to validate runbooks &lt;strong>before&lt;/strong> the real incident.&lt;/li>
&lt;li>&lt;strong>Multi-cluster incident coordination&lt;/strong> — how to coordinate Keep across geographic clusters when an incident affects multiple regions.&lt;/li>
&lt;li>&lt;strong>CMDB and procurement integration&lt;/strong> — the &lt;code>RMA → ticket → ServiceNow → hardware replacement&lt;/code> cycle automated via workflow.&lt;/li>
&lt;li>&lt;strong>LLM forensics&lt;/strong> — extracting the full OTel trace of a request affected by an incident, with redacted PII, kept in an evidence vault.&lt;/li>
&lt;/ul>
&lt;h2 id="see-also">See also&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/anatomy-dcgm-vllm-metrics-analogies-documented-anomalies/">Anatomy of the twelve DCGM and five vLLM metrics&lt;/a> — the documented anomaly per metric that these runbooks resolve.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/gpu-observability-llm-inference-twelve-dcgm-vllm-metrics/">GPU observability for LLM inference&lt;/a> — the compact list and the six critical alerts.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/llm-tracing-opentelemetry-genai/">LLM tracing with OpenTelemetry GenAI&lt;/a> — the OTel trace captured as evidence.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/canary-blue-green-shadow-llm-models/">Canary, blue-green and shadow&lt;/a> — the rollback mechanism RB-06 invokes.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/llm-inference-autoscaling-kubernetes-hpa-keda/">LLM autoscaling on Kubernetes&lt;/a> — the scaling lever RB-01 and RB-05 invoke.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/capacity-planning-on-premise-llm-inference/">Capacity planning&lt;/a> — the head-room budgeted to absorb incidents without an SLO break.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/iso-42001-aims-on-premise-llm-platform/">ISO/IEC 42001 AIMS for on-premise LLMs&lt;/a> — the clause 10 these postmortems materialise.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/technical-controls-ens-iso-42001-eu-ai-act-cross-mapping/">Technical controls ENS × 42001 × EU AI Act&lt;/a> — the control mapping these runbooks satisfy.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/eu-ai-act-technical-dossier-on-premise-llm-architecture/">EU AI Act: mapping to LLM architecture&lt;/a> — art. 73 on serious incidents, which activates the legal sub-workflow.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/five-maturity-levels-platform-under-llm/">Five maturity levels&lt;/a> — codified runbooks are a level 3-4 requirement.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/litellm-day-2-high-availability/">LiteLLM on day 2: high availability&lt;/a> — the cascade of sustained 429s that knocks over the gateway&amp;rsquo;s startup probes and puts the pods into a restart loop.&lt;/li>
&lt;/ul>
&lt;h2 id="references">References&lt;/h2>
&lt;ul>
&lt;li>ISO/IEC 27035-1:2023 — &lt;em>Information security incident management — Principles and process&lt;/em>.&lt;/li>
&lt;li>ISO/IEC 27035-2:2023 — &lt;em>Information security incident management — Guidelines to plan and prepare for incident response&lt;/em>.&lt;/li>
&lt;li>ENS — &lt;em>Real Decreto 311/2022&lt;/em>, Anexo II controles &lt;code>op.exp.7&lt;/code> a &lt;code>op.exp.10&lt;/code>.&lt;/li>
&lt;li>Directiva NIS2 (UE 2022/2555) — art. 23 (notificación de incidentes significativos).&lt;/li>
&lt;li>Reglamento EU AI Act (UE 2024/1689) — art. 73 (reporting of serious incidents).&lt;/li>
&lt;li>ISO/IEC 42001:2023 — &lt;em>AI management system — cláusula 10 (mejora continua)&lt;/em>.&lt;/li>
&lt;li>Keep project — &lt;code>keephq.dev&lt;/code> y &lt;code>github.com/keephq/keep&lt;/code> (documentación de workflows YAML, providers).&lt;/li>
&lt;li>Apache Kafka — &lt;em>Tiered Storage&lt;/em> y &lt;code>cleanup.policy&lt;/code> (docs.confluent.io / kafka.apache.org).&lt;/li>
&lt;li>Confluent — &lt;em>Schema Registry&lt;/em> y best practices para eventos lifecycle.&lt;/li>
&lt;li>NVIDIA — &lt;em>Xid Errors Documentation&lt;/em> y procedimientos de remediación.&lt;/li>
&lt;li>Google SRE Book — &lt;em>Effective Troubleshooting&lt;/em> y &lt;em>Postmortem Culture&lt;/em>.&lt;/li>
&lt;li>Atlassian — &lt;em>Incident Management Handbook&lt;/em> (referencia para severity matrices).&lt;/li>
&lt;/ul></description></item><item><title>RAG on Kafka: a technical reference architecture for streaming datalakes, with fresh embeddings and vector stores that are always up to date</title><link>https://blog.lo0.es/en/posts/rag-on-kafka-reference-architecture-streaming-datalakes/</link><pubDate>Thu, 21 May 2026 06:00:00 +0200</pubDate><guid>https://blog.lo0.es/en/posts/rag-on-kafka-reference-architecture-streaming-datalakes/</guid><description>&lt;h2 id="tldr">TL;DR&lt;/h2>
&lt;p>The piece that blocks enterprise GenAI projects most in 2026 is not the model, nor even the guardrails: it is &lt;strong>data ingestion for RAG&lt;/strong>. Companies hold valuable information in OLTP databases, in operational logs, in SaaS systems, and all of it is quietly changing every second. Batch RAG systems that reindex every night arrive late (the model&amp;rsquo;s answer is backed by a snapshot from 18 hours ago) and open the door to operational hallucinations even when the retriever is perfect. The dominant answer in production in 2026 is to build the RAG piece on top of Kafka as the source of truth: an immutable log, massive throughput, managed schema evolution, and a mature stream processing ecosystem (Flink, Kafka Streams, RisingWave) that makes it possible to transform and embed events as they happen, delivering them to vector stores (Milvus, Qdrant, Weaviate, pgvector) in milliseconds. The canonical pattern: source → CDC with Debezium → Kafka topics → Flink SQL with an embedding UDF → sink connector to a vector store → serving with vLLM or equivalent. The 2026 developments that change the game: Confluent Tableflow turns Kafka topics into Iceberg/Delta tables automatically (read from Snowflake/Databricks/Trino with no ETL, 30-50 % lower TCO); native Flink SQL brings &lt;code>openai_embedding()&lt;/code> and vector search integrated with Cosmos DB and Amazon S3 Vectors; Confluent&amp;rsquo;s official MCP server lets AI agents query Kafka/Flink/Tableflow in natural language. This post develops the end-to-end architecture with manifests, Flink SQL code and concrete numbers.&lt;/p>
&lt;blockquote>
&lt;p>This is the second post in the MLOps series specific to LLMs. The first (&lt;a href="https://blog.lo0.es/en/posts/mlops-for-llms-landscape-2026/">2026 landscape&lt;/a>) set out the framework. Here we go down to the most operational piece of the stack: how a real enterprise system connects to an LLM agent while keeping RAG fresh without falling into explosive complexity.&lt;/p>
&lt;/blockquote>
&lt;h2 id="the-analogy-kafka-as-the-single-source-of-truth">The analogy: Kafka as the &amp;ldquo;single source of truth&amp;rdquo;&lt;/h2>
&lt;p>Anyone who has spent time in distributed systems has seen the pattern again and again: an immutable, append-only, replicated, time-ordered log has become the canonical primitive for rebuilding complex systems. DBAs know it as the write-ahead log (PostgreSQL WAL, MySQL binlog). Event system developers know it as event sourcing. Data architects know it as the Kappa architecture. Kafka is the massive, distributed, mature implementation of that primitive: a log that lives on disk, partitioned to scale, replicated for durability, retained by time or size, readable from any point in history.&lt;/p>
&lt;p>When you think about RAG, this is exactly what you need. A well-designed RAG system has two critical questions: how do you keep the index fresh? And how do you rebuild the index when something breaks? Kafka answers both naturally: fresh because every change at the source is published as an event to the log and the pipeline processes it in milliseconds; rebuildable because the whole log is there: you drop the vector store, you have the Kafka topic from offset 0, and you build the index back exactly as it was.&lt;/p>
&lt;p>There is a second layer to the analogy as well. For a modern GenAI architecture, Kafka plays the role of the WAL of the entire system. Just as the Postgres WAL is the gospel of the database&amp;rsquo;s state (if you lose the DB but keep the WAL, you can rebuild it), the Kafka log is the gospel of the state of the business as a whole: orders, users, transactions, documents. Connecting your AI agent to Kafka means connecting it to the real pulse of the system, not to stale snapshots.&lt;/p>
&lt;h2 id="the-static-rag-problem">The static RAG problem&lt;/h2>
&lt;p>Before presenting the architecture, it is worth pinning down what concrete problem we are solving. The antipattern that trips up most GenAI projects:&lt;/p>
&lt;ol>
&lt;li>A team builds RAG on a static dataset: it dumps Confluence documents, product PDFs, database snapshots.&lt;/li>
&lt;li>It embeds the lot with a nightly cron that regenerates the index every 24 hours.&lt;/li>
&lt;li>It ships the product.&lt;/li>
&lt;li>&lt;strong>Day 2&lt;/strong>: a user asks about a change that happened two hours ago. RAG does not have it; the model answers about the old version.&lt;/li>
&lt;li>The team adds fragile logic: &amp;ldquo;if the query mentions a recent date, escalate to a human agent&amp;rdquo;.&lt;/li>
&lt;li>&lt;strong>Day 30&lt;/strong>: the dataset has moved so much that half the RAG is out of date. The team decides to refactor and migrate to streaming.&lt;/li>
&lt;/ol>
&lt;p>It is the repeated story of so many projects that the ecosystem has learned the lesson: streaming from day 1, even when the volume is low. The operational complexity of a well-designed streaming pipeline is constant; the complexity of migrating from batch to streaming on a live project is enormous.&lt;/p>
&lt;h2 id="from-lambda-to-kappa-to-streaming-rag">From Lambda to Kappa to Streaming RAG&lt;/h2>
&lt;p>Three architectures in historical order:&lt;/p>
&lt;p>&lt;strong>Lambda (the classic big-data design from 2014)&lt;/strong>: two parallel pipelines, one batch for accuracy and one streaming for freshness. The query combines both. It works, but it means maintaining two pipelines.&lt;/p>
&lt;p>&lt;strong>Kappa (Jay Kreps, 2014, mainstream since 2020)&lt;/strong>: a single streaming pipeline. Batch is a special case of streaming (reprocessing from the beginning). It simplifies a great deal.&lt;/p>
&lt;p>&lt;strong>Streaming RAG (emerging in 2025-2026)&lt;/strong>: a specific variant of Kappa where the pipeline&amp;rsquo;s output is embeddings indexed in a vector store that the LLM queries at runtime. The Kafka log is the source of truth, the vector store is a queryable projection.&lt;/p>
&lt;p>The mental conversion: think of the vector store as the materialised view of the Kafka log. If the view is corrupted, you rebuild it from the log. If you want a new view (a different embedding model, a different chunking strategy), you create another consumer of the log and build a second view in parallel.&lt;/p>
&lt;h2 id="the-reference-architecture">The reference architecture&lt;/h2>
&lt;p>On to the diagram. I am going to present the canonical architecture that stabilised in 2026, showing where each component fits:&lt;/p>
&lt;pre tabindex="0">&lt;code>[OLTP DB (Postgres)] [Other sources]
│ │
│ WAL via logical decoding │
▼ ▼
┌──────────────────────────────────────────────────────────┐
│ Debezium / Kafka Connect (Sources) │
└──────────────────────────────────────────────────────────┘
│
▼ produces events
┌──────────────────────────────────────────────────────────┐
│ Kafka cluster │
│ ┌───────────────────────────────────────────────────┐ │
│ │ topic: orders.raw (3 partitions, RF=3) │ │
│ │ topic: users.raw (3 partitions, RF=3) │ │
│ │ topic: documents.raw (6 partitions, RF=3) │ │
│ └───────────────────────────────────────────────────┘ │
│ + Schema Registry (Avro/Protobuf) │
└──────────────────────────────────────────────────────────┘
│
▼ consumes and transforms
┌──────────────────────────────────────────────────────────┐
│ Flink SQL streaming jobs │
│ - chunking text │
│ - calls to the embedding model (UDF) │
│ - enrichment with metadata │
│ - sink to a curated topic: documents.embedded │
└──────────────────────────────────────────────────────────┘
│
┌───────────┼────────────────────┐
▼ ▼ ▼
[Vector store] [Tableflow] [Iceberg/Delta]
Milvus/Qdrant auto-convert for analytics
/pgvector/ topics →
Weaviate tables
│
▼ queried at runtime
┌──────────────────────────────────────────────────────────┐
│ LLM serving (vLLM / SGLang) + Retriever │
│ - receives the agent&amp;#39;s query │
│ - searches top-K in the vector store │
│ - builds prompt + context │
│ - generates an answer with citations │
└──────────────────────────────────────────────────────────┘
&lt;/code>&lt;/pre>&lt;p>The five layers you can see (source, ingestion (CDC), transport (Kafka), processing (Flink), storage (vectors + tables)) are the ones that structure any serious RAG on a datalake in 2026. Let us go through each one.&lt;/p>
&lt;h2 id="layer-1--sources-your-oltp-as-the-starting-point">Layer 1 — Sources: your OLTP as the starting point&lt;/h2>
&lt;p>The typical source is an OLTP database (Postgres, MySQL, SQL Server). It is where the live state of the business lives. The technique for extracting changes in real time is Change Data Capture (CDC): reading the database&amp;rsquo;s transaction log (PostgreSQL WAL, MySQL binlog) and turning each commit into a Kafka event.&lt;/p>
&lt;p>The OSS standard is &lt;a href="https://debezium.io/">Debezium&lt;/a>. It supports Postgres, MySQL, SQL Server, MongoDB, Oracle, Cassandra and others. The typical deployment is a Kafka Connect cluster with Debezium connectors.&lt;/p>
&lt;p>An example Debezium configuration for PostgreSQL:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-json" data-lang="json">&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;postgres-orders-connector&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;config&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;connector.class&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;io.debezium.connector.postgresql.PostgresConnector&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;tasks.max&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;1&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;database.hostname&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;postgres.prod.internal&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;database.port&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;5432&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;database.user&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;debezium&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;database.password&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;${secret:postgres-creds}&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;database.dbname&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;ecommerce&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;database.server.name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;ecommerce-prod&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;table.include.list&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;public.orders,public.users,public.products&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;publication.autocreate.mode&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;filtered&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;slot.name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;debezium_slot&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;plugin.name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;pgoutput&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;topic.prefix&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;ecommerce&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;key.converter&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;io.confluent.connect.avro.AvroConverter&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;value.converter&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;io.confluent.connect.avro.AvroConverter&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;key.converter.schema.registry.url&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;http://schema-registry:8081&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;value.converter.schema.registry.url&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;http://schema-registry:8081&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>For each commit in the database, this produces an Avro event on the corresponding topic (&lt;code>ecommerce.public.orders&lt;/code>, &lt;code>ecommerce.public.users&lt;/code>, and so on) carrying the change: type (INSERT/UPDATE/DELETE), values before and after, commit timestamp, position in the WAL.&lt;/p>
&lt;p>A simpler alternative for 2026: &lt;a href="https://risingwave.com/">RisingWave&lt;/a> can read the Postgres WAL directly, with no Debezium or Kafka Connect in between. When the case is CDC only, with no other sources, it is operationally simpler. For architectures with multiple sources (CDC + APIs + scrapers + logs), Debezium remains the standard piece.&lt;/p>
&lt;h2 id="layer-2--kafka-as-transport-and-persistence">Layer 2 — Kafka as transport and persistence&lt;/h2>
&lt;p>The Kafka cluster is where all events land. Key operational decisions:&lt;/p>
&lt;h3 id="topics-raw-vs-curated">Topics: raw vs curated&lt;/h3>
&lt;p>The convention that settled in 2026:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>&lt;code>*.raw&lt;/code>&lt;/strong>: the raw event exactly as it arrived. Untransformed CDC, unparsed application logs.&lt;/li>
&lt;li>&lt;strong>&lt;code>*.cleaned&lt;/code>&lt;/strong>: after dedup, schema validation, type normalisation.&lt;/li>
&lt;li>&lt;strong>&lt;code>*.enriched&lt;/code>&lt;/strong>: after adding metadata (geolocation, cross identifiers, and so on).&lt;/li>
&lt;li>&lt;strong>&lt;code>*.embedded&lt;/code>&lt;/strong>: the event with its vector embedding already computed.&lt;/li>
&lt;/ul>
&lt;p>Multi-stage topics allow debugging per layer and partial reprocessing: if you change the embedding model, discarding &lt;code>*.embedded&lt;/code> and rebuilding from &lt;code>*.enriched&lt;/code> costs hours; rebuilding from &lt;code>*.raw&lt;/code> costs days.&lt;/p>
&lt;h3 id="schema-registry">Schema Registry&lt;/h3>
&lt;p>Without a schema registry, topics break silently when someone changes the schema at the source. &lt;a href="https://docs.confluent.io/platform/current/schema-registry/index.html">Confluent Schema Registry&lt;/a> or the OSS &lt;a href="https://www.apicur.io/registry/">Apicurio&lt;/a> are the dominant options.&lt;/p>
&lt;p>Common formats:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Avro&lt;/strong>: versioned schema, strict evolution rules. The historical default.&lt;/li>
&lt;li>&lt;strong>Protobuf&lt;/strong>: compatible with gRPC stacks, good performance.&lt;/li>
&lt;li>&lt;strong>JSON Schema&lt;/strong>: textual, debuggable by eye, less efficient.&lt;/li>
&lt;/ul>
&lt;p>For RAG on Kafka we recommend Avro by default. Schema evolution matters because source tables change over time, and an unversioned schema breaks downstream consumers.&lt;/p>
&lt;h3 id="partitions-replication-and-retention">Partitions, replication and retention&lt;/h3>
&lt;p>Operational decisions for RAG topics:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Partitions&lt;/strong>: typically 3-12. More partitions means more parallelism in the Flink consumer, but more overhead. The rule of thumb: partitions = expected peak events/s ÷ 1000.&lt;/li>
&lt;li>&lt;strong>Replication factor&lt;/strong>: 3 as a minimum in production. Replication protects against broker failure; with RAG, the cost of losing a topic can be weeks of re-embedding.&lt;/li>
&lt;li>&lt;strong>Retention&lt;/strong>: for topics that feed RAG, use long retention or compaction by key. If document &lt;code>doc-42&lt;/code> changes 100 times, compaction keeps only the last state per key, leaving a smaller, rebuildable log. For data that is never updated (historical logs), retention by time (90 days, 1 year).&lt;/li>
&lt;/ul>
&lt;h3 id="cross-cluster-replication">Cross-cluster replication&lt;/h3>
&lt;p>For multi-region or multi-cloud deployments, MirrorMaker 2 or &lt;a href="https://docs.confluent.io/platform/current/multi-dc-deployments/cluster-linking/index.html">Cluster Linking&lt;/a> (Confluent) replicate topics between Kafka clusters. RAG can then query the local cluster without crossing regions.&lt;/p>
&lt;h2 id="layer-3--flink-as-the-streaming-processor">Layer 3 — Flink as the streaming processor&lt;/h2>
&lt;p>&lt;a href="https://flink.apache.org/">Apache Flink&lt;/a> is the dominant stream processing piece in 2026. Apache 2.0, a mature distribution, a broad ecosystem. The main alternative is Kafka Streams (simpler, Java-only); RisingWave is the emerging option for pure SQL cases.&lt;/p>
&lt;p>What Flink adds to Kafka:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Stateful streaming&lt;/strong>: time-based aggregations, joins between streams, sessions.&lt;/li>
&lt;li>&lt;strong>Exactly-once semantics&lt;/strong>: with checkpoint coordination.&lt;/li>
&lt;li>&lt;strong>Watermarks&lt;/strong>: correct handling of out-of-order events.&lt;/li>
&lt;li>&lt;strong>UDFs in Python/Java&lt;/strong>: including calls to LLM models.&lt;/li>
&lt;/ul>
&lt;h3 id="flink-sql-the-most-operational-piece">Flink SQL: the most operational piece&lt;/h3>
&lt;p>Flink SQL is the most usable part of Flink for data engineers who are not streaming experts. Here is a realistic RAG pipeline example:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="c1">-- 1. Define the source: Kafka topic with CDC events from documents
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="k">CREATE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">TABLE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">documents_raw&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">doc_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">STRING&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">title&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">STRING&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">body&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">STRING&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">category&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">STRING&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">updated_at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">TIMESTAMP_LTZ&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">3&lt;/span>&lt;span class="p">),&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">PRIMARY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">KEY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">doc_id&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NOT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">ENFORCED&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">WITH&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;connector&amp;#39;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;upsert-kafka&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;topic&amp;#39;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;ecommerce.public.documents&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;properties.bootstrap.servers&amp;#39;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;kafka:9092&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;key.format&amp;#39;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;avro-confluent&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;value.format&amp;#39;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;avro-confluent&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;value.fields-include&amp;#39;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;EXCEPT_KEY&amp;#39;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1">-- 2. Define the sink: vector store via an intermediate Kafka topic
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="k">CREATE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">TABLE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">documents_embedded&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">doc_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">STRING&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">chunk_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">INT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">title&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">STRING&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">chunk_text&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">STRING&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">category&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">STRING&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">embedding&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">ARRAY&lt;/span>&lt;span class="o">&amp;lt;&lt;/span>&lt;span class="nb">FLOAT&lt;/span>&lt;span class="o">&amp;gt;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">embedded_at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">TIMESTAMP_LTZ&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">3&lt;/span>&lt;span class="p">),&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">PRIMARY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">KEY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">doc_id&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">chunk_id&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NOT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">ENFORCED&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">WITH&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;connector&amp;#39;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;upsert-kafka&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;topic&amp;#39;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;rag.documents.embedded&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;properties.bootstrap.servers&amp;#39;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;kafka:9092&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;key.format&amp;#39;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;json&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;value.format&amp;#39;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;json&amp;#39;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1">-- 3. UDF for chunking (defined in Python or Java)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">-- CREATE TEMPORARY FUNCTION chunk_text AS &amp;#39;com.example.ChunkingUDF&amp;#39;;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1">-- 4. Pipeline: chunk, embed, write to the sink
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="k">INSERT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">INTO&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">documents_embedded&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">SELECT&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">doc_id&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">chunk_idx&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">chunk_id&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">title&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">chunk&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">chunk_text&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">category&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">OPENAI_EMBEDDING&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">chunk&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;text-embedding-3-small&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">embedding&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">CURRENT_TIMESTAMP&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">embedded_at&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">documents_raw&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">CROSS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">JOIN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">UNNEST&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">chunk_text&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">body&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">512&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">64&lt;/span>&lt;span class="p">))&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">WITH&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">ORDINALITY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">t&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">chunk&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">chunk_idx&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>What happens here, line by line:&lt;/p>
&lt;ul>
&lt;li>The &lt;code>documents_raw&lt;/code> table reads the CDC topic in upsert-kafka mode (each new event on the same key replaces the previous one). This correctly reflects the semantics of &amp;ldquo;this is the latest version of doc 42&amp;rdquo;.&lt;/li>
&lt;li>The &lt;code>documents_embedded&lt;/code> table will be the intermediate topic where Flink writes the embedded chunks.&lt;/li>
&lt;li>The &lt;code>chunk_text&lt;/code> UDF (defined in Python or Java) splits each doc into 512-token chunks with an overlap of 64.&lt;/li>
&lt;li>The &lt;code>INSERT INTO&lt;/code> query runs continuously: every new event in &lt;code>documents_raw&lt;/code> is chunked, each chunk is embedded with &lt;code>OPENAI_EMBEDDING&lt;/code> (a built-in Flink SQL function in Confluent Cloud 2026), and written to the embedded topic.&lt;/li>
&lt;/ul>
&lt;p>&lt;code>OPENAI_EMBEDDING&lt;/code> can be swapped for a custom function that calls a self-hosted model (vLLM with an encoder), SentenceTransformers, or a managed service. The syntax is the same; you change the provider.&lt;/p>
&lt;h3 id="watermarks-and-late-events">Watermarks and late events&lt;/h3>
&lt;p>For cases where an event can arrive late (for example, the Postgres WAL falls behind because of a network blip), Flink lets you define watermarks:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">CREATE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">TABLE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">documents_raw&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">doc_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">STRING&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">title&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">STRING&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">body&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">STRING&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">updated_at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">TIMESTAMP_LTZ&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">3&lt;/span>&lt;span class="p">),&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">WATERMARK&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">FOR&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">updated_at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">updated_at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">INTERVAL&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;5&amp;#39;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">MINUTE&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">WITH&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(...)&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This tells Flink &amp;ldquo;assume no event arrives more than 5 minutes late relative to the event timestamp&amp;rdquo;. For temporal joins and aggregations, Flink uses the watermark to decide when to &amp;ldquo;close&amp;rdquo; a window.&lt;/p>
&lt;h2 id="layer-4--sinks-to-vector-stores">Layer 4 — Sinks to vector stores&lt;/h2>
&lt;p>The last step is indexing the embeddings in a vector store. Three patterns in 2026:&lt;/p>
&lt;h3 id="pattern-a--direct-kafka-connect-sink">Pattern A — direct Kafka Connect sink&lt;/h3>
&lt;p>Each vector store has its official connector:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>&lt;a href="https://github.com/zilliztech/kafka-connect-milvus">Milvus&lt;/a>&lt;/strong>: official Zilliz sink connector. Supports named/unnamed dense/sparse vectors.&lt;/li>
&lt;li>&lt;strong>&lt;a href="https://github.com/qdrant/qdrant-kafka">Qdrant&lt;/a>&lt;/strong>: official sink connector. Supports dense, sparse, multi-vector.&lt;/li>
&lt;li>&lt;strong>pgvector&lt;/strong>: has no dedicated connector, but the &lt;a href="https://www.confluent.io/hub/confluentinc/kafka-connect-jdbc">JDBC Sink Connector&lt;/a> is used with custom SQL.&lt;/li>
&lt;li>&lt;strong>Weaviate&lt;/strong>: community connector.&lt;/li>
&lt;li>&lt;strong>LanceDB&lt;/strong>: community connector.&lt;/li>
&lt;/ul>
&lt;p>An example Milvus sink configuration:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-json" data-lang="json">&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;milvus-rag-embeddings-sink&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;config&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;connector.class&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;com.milvus.io.kafka.MilvusSinkConnector&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;tasks.max&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;3&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;topics&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;rag.documents.embedded&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;milvus.host&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;milvus.prod.internal&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;milvus.port&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;19530&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;milvus.collection.name&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;documents&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;milvus.collection.dim&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;1536&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;milvus.collection.partition&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;default&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;key.converter&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;org.apache.kafka.connect.storage.StringConverter&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;value.converter&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;org.apache.kafka.connect.json.JsonConverter&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;value.converter.schemas.enable&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="kc">false&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Three parallel tasks (&lt;code>tasks.max: 3&lt;/code>) consume the embedded topic and write to the Milvus collection. Latency from &amp;ldquo;event in Kafka&amp;rdquo; to &amp;ldquo;indexable vector in Milvus&amp;rdquo; is typically &amp;lt;5 seconds.&lt;/p>
&lt;h3 id="pattern-b--pgvector-with-a-direct-cdc-pipe">Pattern B — pgvector with a direct CDC pipe&lt;/h3>
&lt;p>For teams that already live in PostgreSQL, pgvector is the lowest-friction option. The pattern: the same source Postgres cluster holds a second DB for embeddings with the pgvector extension enabled; the Flink pipeline writes to it directly over JDBC.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="c1">-- On the Postgres cluster with pgvector enabled
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="k">CREATE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">EXTENSION&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">IF&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NOT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">EXISTS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">vector&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">CREATE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">TABLE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">document_embeddings&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">doc_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">TEXT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">chunk_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">INT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">chunk_text&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">TEXT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">category&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">TEXT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">embedding&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">vector&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">1536&lt;/span>&lt;span class="p">),&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">embedded_at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">TIMESTAMP&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">PRIMARY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">KEY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">doc_id&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">chunk_id&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">CREATE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">INDEX&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">ON&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">document_embeddings&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">USING&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">hnsw&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">embedding&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">vector_cosine_ops&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">WITH&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">m&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">16&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">ef_construction&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">64&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Advantages: the same DBA operates everything, transactionality across tables, trivial joins with relational metadata. Limitation: beyond 10M vectors, pgvector performance starts to give way compared with dedicated systems.&lt;/p>
&lt;h3 id="pattern-c--confluent-tableflow--iceberg--flink-sql-vector-search">Pattern C — Confluent Tableflow → Iceberg + Flink SQL vector search&lt;/h3>
&lt;p>This is the 2026 development that changes the mechanics. &lt;a href="https://www.confluent.io/product/tableflow/">Confluent Tableflow&lt;/a> materialises Kafka topics automatically as Apache Iceberg or Delta Lake tables. Features:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>No ETL pipeline&lt;/strong>: you do not write Flink/Spark jobs to move Kafka into a table. Tableflow does it.&lt;/li>
&lt;li>&lt;strong>Automatic schema evolution&lt;/strong>: changes to the topic schema are reflected in the table.&lt;/li>
&lt;li>&lt;strong>Unified catalogue&lt;/strong>: the table appears in Glue, Unity Catalog, Snowflake, Databricks. Any analytical engine queries it without copying data.&lt;/li>
&lt;li>&lt;strong>Native CDC&lt;/strong>: handles inserts, updates and deletes correctly.&lt;/li>
&lt;li>&lt;strong>30-50 % lower TCO&lt;/strong> according to the figures Confluent publishes against traditional pipelines.&lt;/li>
&lt;/ul>
&lt;p>And since 2026, Tableflow + Flink SQL offer native vector search integrated with Cosmos DB and Amazon S3 Vectors. The RAG query can be made directly in Flink SQL:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">SELECT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">doc_id&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">chunk_text&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">category&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">documents_embedded&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">WHERE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">VECTOR_SEARCH&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">embedding&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">OPENAI_EMBEDDING&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;user query&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;text-embedding-3-small&amp;#39;&lt;/span>&lt;span class="p">),&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">top_k&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">10&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">7&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">ORDER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">BY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">VECTOR_SEARCH_SCORE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">DESC&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This unifies layers that used to be separate (vector store + analytics). For many cases, it removes the need to maintain a dedicated vector store.&lt;/p>
&lt;h2 id="confluents-official-mcp-server">Confluent&amp;rsquo;s official MCP server&lt;/h2>
&lt;p>One piece added in 2026 deserves a mention: Confluent has published an official MCP server that exposes Kafka, Flink and Tableflow as tools accessible to AI agents over MCP. Any MCP client (Claude Desktop, Cursor, your own agents) can:&lt;/p>
&lt;ul>
&lt;li>List topics, read recent messages, publish to topics.&lt;/li>
&lt;li>Run Flink SQL queries in natural language (&amp;ldquo;give me the orders from the last 24 hours worth more than 1000 €&amp;rdquo;).&lt;/li>
&lt;li>Query Tableflow Iceberg tables.&lt;/li>
&lt;li>Manage Kafka Connect connectors.&lt;/li>
&lt;/ul>
&lt;p>This closes the circle: as well as reading data from the datalake through RAG (with vector search), your AI agent can write data to the log (through MCP) and trigger transformations (through Flink SQL in natural language). It is the deepest point of fusion between LLM ops and data ops this year.&lt;/p>
&lt;p>A connection with the earlier series: this MCP server emits traces with the OpenTelemetry GenAI MCP semantic conventions we covered in the &lt;a href="https://blog.lo0.es/en/posts/mcp-deep-observability-opentelemetry/">MCP observability post&lt;/a>. The spans show up in Langfuse, Phoenix or your OTel backend with the right cardinality. Zero instrumentation code.&lt;/p>
&lt;h2 id="vector-stores-a-2026-comparison">Vector stores: a 2026 comparison&lt;/h2>
&lt;p>The five dominant options:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Vector store&lt;/th>
&lt;th>Licence&lt;/th>
&lt;th>Operation&lt;/th>
&lt;th>Where it fits&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;strong>pgvector&lt;/strong>&lt;/td>
&lt;td>Postgres ext, OSS&lt;/td>
&lt;td>Your DBA&lt;/td>
&lt;td>&amp;lt;10M vectors, Postgres-heavy team&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Qdrant&lt;/strong>&lt;/td>
&lt;td>Apache 2.0&lt;/td>
&lt;td>Self-host or managed&lt;/td>
&lt;td>Mid-scale, performance focus&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Milvus&lt;/strong>&lt;/td>
&lt;td>Apache 2.0&lt;/td>
&lt;td>Self-host or Zilliz Cloud&lt;/td>
&lt;td>Large-scale, scalability focus&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Weaviate&lt;/strong>&lt;/td>
&lt;td>BSD-3&lt;/td>
&lt;td>Self-host or managed&lt;/td>
&lt;td>Native hybrid search, semantically rich&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>LanceDB&lt;/strong>&lt;/td>
&lt;td>Apache 2.0&lt;/td>
&lt;td>Embedded or serverless&lt;/td>
&lt;td>Small-medium, simplicity&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The choice depends on:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Scale&lt;/strong>: pgvector falls short beyond 10M vectors. Milvus and Qdrant scale to billions.&lt;/li>
&lt;li>&lt;strong>Hybrid search&lt;/strong>: Weaviate brings lexical + vector natively. Others support it but less integrated.&lt;/li>
&lt;li>&lt;strong>Operation&lt;/strong>: pgvector if you already run Postgres. Qdrant if you want simplicity. Milvus if you need maximum scale.&lt;/li>
&lt;li>&lt;strong>Cloud managed&lt;/strong>: Zilliz Cloud for Milvus, Qdrant Cloud for Qdrant, Pinecone if you want pure SaaS (with no OSS behind it).&lt;/li>
&lt;/ul>
&lt;h2 id="freshness-vs-accuracy-the-operational-trade-off">Freshness vs accuracy: the operational trade-off&lt;/h2>
&lt;p>A critical decision any RAG system on Kafka must answer: when is a new document considered &amp;ldquo;live&amp;rdquo; in the index?&lt;/p>
&lt;p>Three options:&lt;/p>
&lt;p>&lt;strong>Synchronous streaming&lt;/strong>: the event reaches Kafka, Flink embeds it, the sink writes it to the vector store, and only then is it considered live. Typical latency: 1-5 seconds. The best freshness. But if the embedding model fails or the vector store is slow, events pile up in the topic.&lt;/p>
&lt;p>&lt;strong>Asynchronous streaming with a baseline&lt;/strong>: the event is considered live immediately; a background process embeds it when it can. In the meantime, queries asking for that document do not find it. Typical latency: 5-60 seconds. Acceptable for most applications.&lt;/p>
&lt;p>&lt;strong>Micro-batch&lt;/strong>: processing happens in mini-batches every 1-5 minutes. Less efficient than continuous streaming but more stable under variable load. Latency: 1-5 minutes.&lt;/p>
&lt;p>The decision depends on the product&amp;rsquo;s SLA. For customer support chatbots, 5-60 seconds is acceptable. For systems that react to critical events (financial prices, alarms), synchronous streaming is necessary.&lt;/p>
&lt;h2 id="schema-evolution-and-re-embedding">Schema evolution and re-embedding&lt;/h2>
&lt;p>When the embedding model changes (you move from &lt;code>text-embedding-3-small&lt;/code> to &lt;code>text-embedding-3-large&lt;/code>, or from OpenAI to Cohere), the vectors already in the index are incompatible: different dimensions, different semantic spaces. The distance between an old vector and a new one means nothing.&lt;/p>
&lt;p>The standard pattern for handling this: &lt;strong>dual-index&lt;/strong> during the migration.&lt;/p>
&lt;ol>
&lt;li>&lt;strong>T0&lt;/strong>: the active index is V1 (embedding model A).&lt;/li>
&lt;li>&lt;strong>T1&lt;/strong>: a parallel pipeline starts writing to a V2 index (embedding model B), consuming the topic from offset 0 (reprocessing the whole log).&lt;/li>
&lt;li>&lt;strong>T2&lt;/strong>: V2 has caught up with the present.&lt;/li>
&lt;li>&lt;strong>T3&lt;/strong>: you switch the retriever over to V2.&lt;/li>
&lt;li>&lt;strong>T4&lt;/strong>: a week later, you discard V1.&lt;/li>
&lt;/ol>
&lt;p>The Kafka log makes this pattern feasible because it is &lt;strong>immutable and reproducible&lt;/strong>. Without the log, this pattern becomes a weeks-long data migration project.&lt;/p>
&lt;h2 id="operational-pitfalls">Operational pitfalls&lt;/h2>
&lt;h3 id="topics-without-adequate-retention">Topics without adequate retention&lt;/h3>
&lt;p>Configuring topics with 7-day retention on the grounds that &amp;ldquo;I already have the vector store&amp;rdquo; means losing the ability to rebuild if the vector store fails. &lt;strong>Long retention (90+ days) or compaction by key&lt;/strong> for topics that feed RAG.&lt;/p>
&lt;h3 id="heavy-cdc-during-peak-load">Heavy CDC during peak load&lt;/h3>
&lt;p>Debezium reading the WAL at peak hours can hit the source database&amp;rsquo;s performance. &lt;strong>A dedicated read replica&lt;/strong> for Debezium, not the production primary. Or use logical replication restricted to just the tables you need.&lt;/p>
&lt;h3 id="embedding-cost-run-away">Embedding cost run-away&lt;/h3>
&lt;p>&lt;code>OPENAI_EMBEDDING&lt;/code> on every event of a topic with millions of messages a day comes to thousands of USD per month. Strategies: filter before embedding (only embed what adds value); deduplicate by content hash; use self-hosted open-source embedding models (BGE, E5, GTE) when the cloud cost is prohibitive.&lt;/p>
&lt;h3 id="slow-re-embedding-due-to-limited-throughput">Slow re-embedding due to limited throughput&lt;/h3>
&lt;p>Recomputing 10M embeddings with the OpenAI API at 3000 req/min takes 55 hours. If you wait for an incident to re-embed, that is two days without service. &lt;strong>Embedding throughput is an explicit capacity planning item&lt;/strong>; reserve capacity or keep an offline job ready to start.&lt;/p>
&lt;h3 id="downstream-schema-breaks">Downstream schema breaks&lt;/h3>
&lt;p>A change to the raw topic&amp;rsquo;s schema breaks Flink jobs downstream. &lt;strong>Schema Registry with BACKWARD compatibility made mandatory&lt;/strong>; never ALLOW_ALL. And test schema evolution in CI.&lt;/p>
&lt;h3 id="a-vector-store-with-no-backup">A vector store with no backup&lt;/h3>
&lt;p>Your vector store holds 50M vectors. It is the only copy (the topics expired). A failure wipes it. &lt;strong>Vector stores must be backed up&lt;/strong> like any primary persistence layer. For Milvus/Qdrant: periodic snapshots. For pgvector: plain pg_dump.&lt;/p>
&lt;h3 id="multi-region-without-cross-cluster-replication">Multi-region without cross-cluster replication&lt;/h3>
&lt;p>Your RAG serves users in the US and the EU. The vector store is in US-east. Latency from the EU = 100 ms+ per query. &lt;strong>MirrorMaker or Cluster Linking&lt;/strong> to replicate topics and vector stores in both regions.&lt;/p>
&lt;h2 id="what-we-have-not-covered">What we have not covered&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Hybrid search in production&lt;/strong>: combining BM25/lexical + vector + reranker. A topic for its own post.&lt;/li>
&lt;li>&lt;strong>Multimodal RAG&lt;/strong>: indexing images, audio and video alongside text. Multimodal embeddings (CLIP, Imagebind), a specific architecture.&lt;/li>
&lt;li>&lt;strong>GraphRAG&lt;/strong>: using structured knowledge (knowledge graphs) as well as vector retrieval. Microsoft GraphRAG, LlamaIndex KnowledgeGraphQueryEngine.&lt;/li>
&lt;li>&lt;strong>RAG with multi-tenant ACLs&lt;/strong>: filtering by permissions at runtime. The pattern uses metadata in the vector store + server-side filters.&lt;/li>
&lt;li>&lt;strong>Query rewriting with an LLM&lt;/strong>: using a first LLM to expand the query before retrieval (HyDE, multi-query, step-back prompting).&lt;/li>
&lt;/ul>
&lt;h2 id="references">References&lt;/h2>
&lt;p>Kafka and stream processing:&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://kafka.apache.org/">Apache Kafka&lt;/a> y &lt;a href="https://debezium.io/">Debezium&lt;/a>.&lt;/li>
&lt;li>&lt;a href="https://docs.confluent.io/platform/current/schema-registry/index.html">Confluent Schema Registry&lt;/a> y &lt;a href="https://www.apicur.io/registry/">Apicurio Registry&lt;/a>.&lt;/li>
&lt;li>&lt;a href="https://flink.apache.org/">Apache Flink&lt;/a> y &lt;a href="https://nightlies.apache.org/flink/flink-docs-stable/docs/dev/table/sql/overview/">Flink SQL docs&lt;/a>.&lt;/li>
&lt;li>&lt;a href="https://risingwave.com/">RisingWave&lt;/a> — alternativa SQL streaming con embedding built-in.&lt;/li>
&lt;/ul>
&lt;p>Vector store connectors:&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://github.com/zilliztech/kafka-connect-milvus">Milvus Sink Connector (Zilliz, GitHub)&lt;/a>.&lt;/li>
&lt;li>&lt;a href="https://milvus.io/docs/kafka-connect-milvus.md">Connect Apache Kafka with Milvus (docs)&lt;/a>.&lt;/li>
&lt;li>&lt;a href="https://github.com/qdrant/qdrant-kafka">Qdrant Kafka Sink (GitHub)&lt;/a>.&lt;/li>
&lt;li>&lt;a href="https://callsphere.ai/blog/vector-database-benchmarks-2026-pgvector-qdrant-weaviate-milvus-lancedb">Vector Database Benchmarks 2026&lt;/a>.&lt;/li>
&lt;li>&lt;a href="https://streamkap.com/resources-and-guides/streaming-vector-databases-platform-comparison">Streaming to Vector Databases (Streamkap)&lt;/a>.&lt;/li>
&lt;/ul>
&lt;p>Tableflow and 2026 architecture:&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://www.confluent.io/product/tableflow/">Tableflow — Confluent&lt;/a>.&lt;/li>
&lt;li>&lt;a href="https://www.confluent.io/blog/tableflow-ga-kafka-snowflake-iceberg/">Tableflow GA: Real-Time Kafka to Iceberg (Confluent Blog)&lt;/a>.&lt;/li>
&lt;li>&lt;a href="https://www.confluent.io/blog/tableflow-delta-lake-databricks-unity-catalog-ga/">Tableflow + Databricks Unity Catalog (Confluent Blog)&lt;/a>.&lt;/li>
&lt;li>&lt;a href="https://www.confluent.io/blog/data-lake-governance-tableflow/">Better-Governed Data Lake Architectures with Tableflow (Confluent Blog)&lt;/a>.&lt;/li>
&lt;li>&lt;a href="https://www.kai-waehner.de/blog/2025/12/10/top-trends-for-data-streaming-with-apache-kafka-and-flink-in-2026/">Top Trends for Data Streaming with Kafka and Flink in 2026 (Kai Waehner)&lt;/a>.&lt;/li>
&lt;/ul>
&lt;p>Streaming RAG:&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://risingwave.com/blog/rag-architecture-2026/">RAG Architecture in 2026: How to Keep Retrieval Actually Fresh (RisingWave)&lt;/a>.&lt;/li>
&lt;li>&lt;a href="https://streamkap.com/resources-and-guides/streaming-to-vector-databases">Streaming CDC Events to Vector Databases (Streamkap)&lt;/a>.&lt;/li>
&lt;li>&lt;a href="https://www.kai-waehner.de/blog/2023/11/08/apache-kafka-flink-vector-database-llm-real-time-genai/">Apache Kafka + Vector Database + LLM = Real-Time GenAI (Kai Waehner)&lt;/a>.&lt;/li>
&lt;li>&lt;a href="https://arxiv.org/pdf/2508.05662">From Static to Dynamic: A Streaming RAG Approach (arxiv 2508.05662)&lt;/a>.&lt;/li>
&lt;li>&lt;a href="https://developer.confluent.io/confluent-tutorials/gen-ai-vector-embedding/flinksql/">How to generate vector embeddings for RAG with Flink SQL (Confluent Developer)&lt;/a>.&lt;/li>
&lt;li>&lt;a href="https://dasroot.net/posts/2026/03/event-driven-architectures-ai-pipelines-kafka-flink/">Event-Driven Architectures for AI Pipelines (dasroot)&lt;/a>.&lt;/li>
&lt;/ul>
&lt;p>Cross-references:&lt;/p>
&lt;ul>
&lt;li>Previous post: &lt;a href="https://blog.lo0.es/en/posts/mlops-for-llms-landscape-2026/">MLOps specific to LLMs in 2026: the landscape&lt;/a>.&lt;/li>
&lt;li>Data series: &lt;a href="https://blog.lo0.es/en/posts/postgresql-qdrant-rag-ingestion-postman-syncing-two-worlds/">PostgreSQL + Qdrant at the ingestion stage&lt;/a>, &lt;a href="https://blog.lo0.es/en/posts/rag-corpus-curation-active-librarian/">RAG corpus curation: the active librarian&lt;/a>, &lt;a href="https://blog.lo0.es/en/posts/reranker-hybrid-retrieval-five-chunks-llm-reads/">Reranker and hybrid retrieval&lt;/a> — the four pieces that close the Data block: streaming, ingest, curation and retrieval.&lt;/li>
&lt;li>Post-tracing series: &lt;a href="https://blog.lo0.es/en/posts/evals-llm-layer-after-tracing/">Evals&lt;/a>, &lt;a href="https://blog.lo0.es/en/posts/llm-guardrails-safety-four-lines-of-defence/">Guardrails&lt;/a>, &lt;a href="https://blog.lo0.es/en/posts/mcp-deep-observability-opentelemetry/">MCP observability&lt;/a>, &lt;a href="https://blog.lo0.es/en/posts/ebpf-local-inference-statistical-drift-detection/">eBPF + drift&lt;/a>.&lt;/li>
&lt;li>eBPF series: &lt;a href="https://blog.lo0.es/en/posts/ebpf-zero-to-cilium-kernel-tcp-ip-bypass/">eBPF from zero to Cilium&lt;/a>, &lt;a href="https://blog.lo0.es/en/posts/tetragon-cilium-security-syscalls-kernel/">Tetragon&lt;/a>, &lt;a href="https://blog.lo0.es/en/posts/hubble-ebpf-network-observability-ai-agents/">Hubble&lt;/a>, &lt;a href="https://blog.lo0.es/en/posts/agentsight-llm-tracing-ebpf-zero-instrumentation/">AgentSight&lt;/a>.&lt;/li>
&lt;/ul></description></item></channel></rss>