Event store and ingestion
The event ingester turns Armada event messages from Pulsar into compact event records and stores them in Redis streams. It keeps job-set history available for readers while exposing health, size, and storage-use signals for operators.
Ingestion pipeline
The pipeline consumes the job-set event topic and moves each message through decode, batch, conversion, storage, and acknowledgement stages. The shared ingestion pipeline owns the handoff between stages, so a Pulsar message is acknowledged only after the store has finished its attempt.
This diagram shows how an Armada event message becomes a stored history record.
flowchart LR
P[Pulsar job-set event topic] --> U[Decode message and keep message ID]
U --> B[Batch and merge event sequences]
B --> C[Convert to stored event records]
C --> S[Write Redis streams]
S --> A[Acknowledge Pulsar messages]
S --> M[Publish storage and event metrics]
The event ingester uses failover consumption and starts from the earliest available position for its subscription. Batch size and batch time limit the trade-off between write efficiency and processing delay. Invalid message payloads are counted and logged, but their message IDs remain in the batch so the pipeline can complete acknowledgement handling.
References: internal/…/ingester.go• L104-139 internal/…/ingestion_pipeline.go• L53-63 internal/…/ingestion_pipeline.go• L215-243 internal/…/ingestion_pipeline.go• L282-303
Event conversion
The event converter changes decoded EventSequence messages into records that the event store can write. It preserves the event data needed for history while removing fields that belong in the Redis key or that should not be exposed through the public event store.
Sequence preparation
The converter combines compatible sequences and applies a maximum output size before serialization. It removes group data because that data can be large. It also removes queue and job-set names from the serialized sequence because those values are stored as the stream identity.
The converter removes private or redundant fields before storage. Cancellation reasons are cleared, startup information on running jobs is removed, and debug messages in job errors are cleared. Debug-only events and job-run error details without Redis history value are removed because Lookout reads that data directly from Pulsar. Lease-expired and pod-lease-returned job-run errors remain for Redis consumers, but their debug messages are cleared.
References: internal/…/conversions.go• L37-60 internal/…/conversions.go• L103-175 internal/…/utils.go• L14-39 pkg/…/events.proto• L64-109
Stored event records
The converter serializes each prepared sequence and compresses the result. A stored record contains the queue, the job-set name, and the compressed event bytes. It also carries the source Pulsar message IDs so the downstream store can return them to the acknowledgement stage.
Serialization or compression errors are processing errors. The converter records the error and skips the affected sequence rather than producing a partial record for it. The size limit therefore protects the store from oversized output, while the model keeps source-message tracking separate from event content.
Event-size metrics describe only events that remain after filtering and are successfully compressed. When enabled, the converter estimates compressed size from the sequence compression ratio and records the uncompressed and estimated compressed bytes by queue and event type.
References: internal/…/conversions.go• L62-102 internal/…/model.go• L7-20 internal/…/conversions_test.go• L385-470
Event storage
The event store is the persistence boundary for user-facing Armada event history. It writes compressed records to Redis streams that are scoped by queue and job set, and it applies the same retention policy to each stream it touches.
Redis stream layout
Each queue and job-set pair has one Redis stream. Its key follows the form Events:{queue}:{jobSetId}. The stream entry stores the compressed sequence under the message field, while the Redis stream entry ID supplies the sequence position for later readers.
The store can write to a main Redis target and an optional replica. This second target supports controlled data migration or a parallel control-plane destination without changing the event record shape. A batch is split before writing when it exceeds either the configured row count or byte limit.
References: internal/…/eventstore.go• L20-35 internal/…/eventstore.go• L46-78 internal/…/eventstore.go• L86-141 internal/…/constants.go• L37-39 internal/…/types.go• L14-43
Write reliability
Redis writes use a pipeline so event entries and stream expiration are submitted as one write group per target. The store retries errors that do not match configured fatal patterns. It returns a final error only after retry handling decides that the operation cannot succeed or the retry window ends.
The sink owns retry behavior. After the sink returns, the pipeline logs any final error and acknowledges the source message unless shutdown cancelled the operation. It then retries the acknowledgement until it succeeds.
References: internal/…/eventstore.go• L91-108 internal/…/eventstore.go• L111-175 internal/…/ingestion_pipeline.go• L215-243
Storage metrics
The ingester reports both processing metrics and Redis stream metrics. Processing metrics describe message flow, event counts, conversion errors, event sizes, and write duration. Redis metrics describe the current shape and use of stored history so operators can see growth and unusually large or old streams.
Processing metrics
The shared event-ingester metric set connects each stage to a useful operational signal:
- Pulsar connection errors and processing errors show whether input can be consumed and decoded.
- Processed-message and processed-event counters show completed pipeline work.
- Per-queue event-size counters show uncompressed size and estimated compressed size by event type.
- Redis write duration records success and failure results for each Redis target.
- Optional processing-delay gauges show the age of messages being handled.
Event-size metrics are optional. When enabled, the converter estimates compressed size per event by applying the sequence compression ratio to each event's uncompressed size. It records these sizes only for events that remain after filtering and are successfully compressed.
References: internal/…/metrics.go• L35-45 internal/…/metrics.go• L103-143 internal/…/metrics.go• L18-31 internal/…/conversions.go• L77-89 internal/…/conversions_test.go• L385-470
Redis stream metrics
The Redis metrics path scans keys with the event-stream prefix and reads stream information and memory use in batches. It extracts queue and job-set identity from each key, skips streams that disappear during a scan, and measures age from the first stream entry.
The collector publishes two views of the result. Queue gauges aggregate stream count, memory, and event count. Top-N gauges identify the largest streams by memory, event count, and age. Histograms show distributions across all scanned streams. Collection state is refreshed on a schedule and served from an atomic snapshot, which keeps Prometheus scrapes from causing Redis work.
Only the elected metrics leader collects and exposes the snapshot. A non-leader clears or withholds state during a leadership change, which prevents stale data from looking current after failover.
References: internal/…/scanner.go• L17-24 internal/…/scanner.go• L31-72 internal/…/scanner.go• L103-183 internal/…/collector.go• L183-225 internal/…/collector.go• L245-280 internal/…/collector.go• L283-401
History consumers
Redis streams are the durable event-history source for services that need to reconstruct job or job-set state. The event ingester owns the write contract. Query and read-model services consume that contract for user-facing history rather than depending on the Pulsar message shape directly.
For the read side, continue with Lookout query services. Lookout reads some debug-only data directly from Pulsar, while its durable event history comes from the Redis store. For the wider relationship between event ingestion, durable history, and its consumers, see Event ingestion and job history.
References: internal/…/eventstore.go• L111-141 internal/…/constants.go• L37-39 pkg/…/events.proto• L64-109
Change checklist
When these files or sections are changed, remember to consider these:
- Changes to the
EventSequencefields or event names must be checked against conversion filtering, serialized history readers, direct Pulsar consumers, and event-size metric labels. - Changes to privacy filtering must be checked against the data that Lookout reads from Pulsar and the event data that Redis readers expect.
- Changes to the Redis key format must stay aligned between event writes, stream-key parsing, and every history reader.
- Changes to batch limits must be checked against both Pulsar acknowledgement grouping and Redis row or byte limits.
- Changes to retention or replica settings must be checked against migration use cases and the expected lifetime of Lookout history.
- Changes to fatal Redis error patterns must preserve the boundary between retryable write failures and errors that should stop progress.
- Changes to metric labels or leader behavior must be checked against dashboards and failover expectations.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| An event payload cannot be decoded | The event sequence is not stored. Its source message still reaches the acknowledgement path. | Deserialization errors are counted and logged while the message ID is retained. |
| An event has no value for Redis history | The event is absent from the stored sequence. A sequence with no remaining events produces no stored record. | Conversion filters debug-only events and non-lifecycle job-run errors before serialization. |
| Serialization or compression fails | The affected converted record is skipped and processing metrics record a conversion error. | Conversion checks both operations before it creates a stored record and records size metrics only after compression succeeds. |
| Redis returns a transient write error | Storage is delayed while the sink retries. | Retry backoff handles non-fatal errors before the sink returns. |
| A Redis error matches a configured fatal pattern | The sink stops retrying and returns an error. The pipeline can then acknowledge the source message even though the record was not stored. | Fatal insertion patterns are compiled from configuration and checked against the error text. |
| A stream disappears during metrics scanning | That stream is absent from the current metrics snapshot. | The scanner skips NOSTREAM, missing, and malformed stream results. |
| The metrics collector is not the leader | Its metrics are cleared or not exposed. | Leader election gates collection and scrape-time exposure. |
| Shutdown cancels a store call | The pipeline stops before normal acknowledgement of the remaining work. | Context cancellation and deadline errors break the sink loop. |
Key files
| File | Why to read it |
|---|---|
| internal/…/ingester.go | Service assembly for Pulsar input, conversion, Redis storage, and optional Redis metrics. |
| internal/…/ingestion_pipeline.go | Shared lifecycle that batches messages, invokes the converter and sink, and acknowledges source messages. |
| internal/…/utils.go | Armada job-set message decode, event counting, batch merge, and event metrics boundary. |
| internal/…/conversions.go | Rules for reducing, sanitizing, serializing, and compressing event sequences. |
| internal/…/model.go | Data contract between conversion and storage. |
| internal/…/eventstore.go | Redis stream write contract, retention, replica writes, and retry behavior. |
| internal/…/scanner.go | Redis stream scan used to build storage-use metrics. |
| internal/…/collector.go | Leader-gated metric snapshot and queue, top-stream, and distribution views. |
| pkg/…/events.proto | Source event model and the job, job-set, and job-run history concepts carried by each sequence. |