Monitor and recover
This guide sets the alerts that tell you a hook, a queue, a view or the registry sync needs attention, then gets a stalled hook moving again, deals with a record that always fails, and clears queue entries pinned far in the future.
Both halves start from the same two signals. A metric, summed over replicas, tells you something is wrong. SHOW SERVING STATUS on one pod tells you what.
Before you start, have:
- featuremeshd exporting its OpenTelemetry metrics to your collector (
telemetry.metrics.exporters, Configure featuremeshd ); - access to the hooks pods' HTTP port ( Reach a pod ), and to the stores the hooks write.
Every metric and its labels are in featuremeshd metrics . The status columns they mirror are in Status and writes . What each failure does to a record, an entry and a value is in Delivery and failures .
1. Aggregate across replicas
Sum the counters over replicas. Take the maximum of the queue gauges, not their sum, since each replica reports the same queue ( featuremeshd metrics ).
2. Set the alerts
| Alert on | Metric | It means | Then |
|---|---|---|---|
| the registry sync failing | time() - featuremeshd.registry.sync.last_success above a few sync periods (60 s each by default), or featuremeshd.serving.definitions with status = ERROR above zero | definitions keep running as loaded, but no CREATE, DROP or RECOMPILE SERVING reaches this replica. Every rollout step waits on it | fix the registry's reachability or token |
| a hook stalled | featuremeshd.hooks.stalled at 1, featuremeshd.hooks.sink.failures rising | it retries the same batch until its source, sink or queue answers, with every partition of that hook this replica holds | Find what holds a hook |
| consumer lag growing for minutes | featuremeshd.hooks.lag | an event hook falls behind its topic | add replicas, up to the topic's partition count ( Replicas and resources ), or find the slow source |
| a queue falling behind | featuremeshd.hooks.queue.oldest_due_age above a few drain periods | the drainer is late. Past EXPIRE, buckets are lost | check the hook's stores, then drain batches |
| entries expired or dropped | featuremeshd.hooks.queue.entries_expired, .entries_dropped above zero | buckets never written, or a late correction to a bucket written before lost | replay and review EXPIRE |
| data errors | featuremeshd.hooks.data_errors | records that do not decode, calls that raise, or calls still failing on a source once their batch has failed for poison_after. All are skipped | read SHOW SERVING WRITES for the codes |
| deletions rising, above all after a deployment | featuremeshd.hooks.deletions | calls raise, and their keys' latest values are removed. A definition that raises on every record removes every key its records reach | roll back the definition ( Tombstones ) |
| a queue's lease changing hands | featuremeshd.hooks.queue.lease_lost rising | a drainer stopped answering long enough for another replica to take its queue ( Leases ). A steady rise is a replica that pauses (memory, CPU) and loses its drains' work | check the pods' memory and CPU |
| a logger dropping rows | featuremeshd.logger.calls_dropped, featuremeshd.logger.rows with outcome dropped_write_failed | the values are served or written, but the log misses them | check the log sink, or raise queue_capacity ( Delivery ) |
| a view failing | featuremeshd.views.runs with outcome = failed | a run's one attempt failed | last.error in SHOW SERVING STATUS |
| serving calls failing or slow | featuremeshd.serving.source.failures rising, featuremeshd.serving.call.duration above your endpoint's budget, both with caller = serving | a source does not answer, or answers late. Calls fail or fall back ( Errors and fallbacks ) | check the source, and measure the statement again ( Deploy ) |
3. Watch what the metrics do not show
- A stalled hook freezes its own gauges.
lagandnewest_record_timemove at each commit, so they stand still while a hook isSTALLED. The queue gauges freeze while drains fail. Pair every lag or queue alert withfeaturemeshd.hooks.stalled. Alert also on the lag your broker's tools show for the consumer group named as the hook. - How far behind a hook reads. On a topic that is never quiet,
time() - featuremeshd.hooks.newest_record_timeis how far behind the hook reads, plus however late producers stamp their records. - A queue's depth is not lateness.
depthalso counts entries not due yet, so it grows before a bucket closes without anything being late. Alert onoldest_due_age. - A burst of data errors with
retriesrising is a partial outage of a source that outlastedpoison_after. Its keys'latestvalues were removed ( A store answers for some keys only ). - A missing bucket reads as zero. An hour without payments has no bucket, and neither has an hour whose bucket is not written yet, or expired. A sum over buckets cannot tell them apart. While
featuremeshd.hooks.queue.oldest_due_agestays under the read's lag tolerance andentries_expiredat zero, a missing bucket is an hour without payments ( Long horizons ). - A view that never landed leaves no series.
featuremeshd.views.last_success_timeexists only on a replica that landed a run since it started. To alert on a view not landing, read its sink's watermark, the same for every replica. Alert when itsrequest_time(the slot published) is older than the schedule's period plus your margin ( How a run lands ). A view withoutSCHEDULEis your orchestrator's to watch. It checks eachRECOMPUTE's outcome by its own deadline ( Run a view from an orchestrator ). - The health endpoint stays healthy while a hook is stalled ( Health is liveness only ).
4. Find what holds a hook
Ask each hooks replica, since each answers for the partitions and queues it holds:
SHOW SERVING STATUS LIKE 'FM.SHOP.%'; A hook that does not move is STALLED. Its MESSAGE holds the details ( A hook's details ):
errornames the source, sink or queue that does not answer, and why;waits_onnames the hookONits statement whose failure holds it;retriesclimbs while the batch is computed again.
SHOW SERVING WRITES LIKE 'FM.SHOP.%' LIMIT 50 lists the last ERROR and DELETE rows, with the partition and offset of each record ( SHOW SERVING WRITES ).
A hook STALLED on its topic, right after a deployment, reads a topic that does not exist, or one whose ACLs refuse its group. It starts once the topic exists or the ACL allows it ( Consumer groups ).
5. A store does not answer
When a sink, a queue, or a source read by every call is down, the hook waits and retries the same batch, with a backoff up to 30 seconds. No record is skipped, and the consumer keeps its partitions ( Failures in a batch ).
Bring the store back. The hook resumes on its own, from the batch it held. Nothing else is needed, unless the outage outlasted a scheduled hook's EXPIRE. A replay then rebuilds its dropped buckets ( Start, backfill and replay ).
6. A store answers for some keys only
When some calls of a batch succeed and others keep failing on a source, the failing ones become data errors once the batch has failed for poison_after, 2 minutes by default. They are skipped, and their keys' latest values are removed.
- Raise
poison_afterin the configuration when a statement reads a store whose partial outages last longer, a clustered store's failover for instance. It costs time, since one bad key then holds the others longer. - Replay the records skipped once the store is back ( Replay a topic ). Their partitions and offsets are in
SHOW SERVING WRITES.
7. One record always fails
A batch whose every call fails keeps retrying, even when it is one record whose key always fails. On a quiet topic, most batches are one record, and every partition of that replica waits behind it. Three ways past it:
Fix the source, so that the key answers.
Drop the record. Add a
WHEREto the hook that excludes it, thenRECOMPILE SERVING.Skip it. Drop the hook, move its group one offset past the record with your broker's tools, and create the hook again:
bash kafka-consumer-groups --bootstrap-server broker:9092 --group prod.FM.SHOP.ON_PAYMENT
--topic payments:3 --reset-offsets --to-offset 18421 --execute # partition 3, the offset after the recordThe steps around the reset are in Replay a topic .
8. An entry pinned far in the future
A scheduled hook whose due time follows the payload's event_time, as a profile's does, can be pinned by a payment dated in the future. A payment stamped a year ahead leaves an entry due in a year. Under POLICY = 'latest', no later payment pulls it back, so the key is not computed again for a year.
Guard the event hook against such records. This WHERE drops a payment dated more than a minute after its Kafka timestamp, which also keeps it out of the index:
CREATE OR REPLACE FEATURES IN FM.TUTORIALS.HOOK_REF AS
PERSIST
on_payment := HOOK(
RUN pay_ps
ON payments AS p
WHERE p[amount] > 0 AND p[event_time] <= p[record_time] + INTERVAL '1 MINUTE'
USING (p[payment_id], p[merchant_id], p[amount], p[event_time])
TO pay_index
WITH (
START = 'earliest'
)
)
;| feature_name VARCHAR | status VARCHAR | message VARCHAR |
|---|---|---|
| FM.TUTORIALS.HOOK_REF.ON_PAYMENT | REPLACED | Feature was replaced |
Remove an entry already pinned by hand. A queue's entries are not keyed by a readable reference ( Queues ), so remove them by due time, while no drain runs them. In a table queue, the lease is the row whose ref_hash is not 32 bytes:
-- PostgreSQL, MySQL/MariaDB: the entries due after 2027-01-01
DELETE FROM minute_queue WHERE due_time > 1798761600 AND octet_length(ref_hash) = 32; # Redis: the same entries, from both keys
redis-cli ZRANGE '{minute_queue}:due' 1798761600 +inf BYSCORE # their hashes
redis-cli ZREM '{minute_queue}:due' <hash> …
redis-cli HDEL '{minute_queue}:entries' <hash> … The next payment of each key queues a new entry, with a due time the guard allows.
Check the alerts and the recovery
- The stalled alert fires, then clears. On a test server, make a sink fail a few times with the test commands ( Test commands ), and watch the alert.
- The hook's
STATUSis back toRUNNING, andfeaturemeshd.hooks.stalledto 0. retriesstops climbing, and each partition'slagfalls.- A scheduled hook's
oldest_due_age_secondsfalls back under a few drain periods.
Common mistakes
- Summing the queue gauges over replicas. Each replica reports the same queue.
- Alerting on lag alone. It stands still while the hook is stalled.
- Restarting the pod on an alert. A stalled hook waits for a store, and a restart does not bring the store back.
- Raising
poison_afterwithout replaying. The records already skipped stay skipped, and theirlatestvalues stay removed. - Deleting queue entries a drain may run. Delete only entries due far in the future, which no drain reads yet.
Related
- Size
RETENTION,EXPIREand memory : the thresholds that turn a late queue into lost buckets. - Tombstones : what a skipped call leaves in its sink.