ClickHouse processor configuration

The memory-service process clickhouse command accepts CLI flags or environment variables. Use the toggle to switch between formats. CLI flags take precedence when both forms configure the same setting.

Config format

Tip: Your format preference is saved across visits.

This page covers the analytics processor. See Service configuration for the Memory Service server.

Memory Service connection

SettingDefaultDescription
--endpoint MEMORY_SERVICE_GRPC_ENDPOINTRequiredMemory Service gRPC endpoint.
--client-id MEMORY_SERVICE_PROCESS_CLIENT_IDRequiredAuthenticated processor client and checkpoint owner.
--api-key MEMORY_SERVICE_API_KEYNoneAPI key for the processor client.
--bearer-token MEMORY_SERVICE_BEARER_TOKENNoneBearer token used instead of an API key.
--grpc-tls MEMORY_SERVICE_PROCESS_GRPC_TLSfalseEnable TLS for the Memory Service gRPC connection.
--grpc-ca-file MEMORY_SERVICE_PROCESS_GRPC_CA_FILENonePEM CA bundle for the gRPC server.
--allow-insecure-grpc MEMORY_SERVICE_PROCESS_ALLOW_INSECURE_GRPCfalsePermit plaintext gRPC for development.

The client must have the Memory Service admin role. A second processor with the same client ID cannot acquire the checkpoint lease.

Export behavior

SettingDefaultDescription
--exporter-id MEMORY_SERVICE_CLICKHOUSE_EXPORTER_IDClient IDStable namespace stored with every exported row.
--disable MEMORY_SERVICE_CLICKHOUSE_DISABLENoneResource or feature selectors to omit from the export.
--tail-only-development MEMORY_SERVICE_CLICKHOUSE_TAIL_ONLY_DEVELOPMENTfalseSkip backfill and begin at the current durable tail. Readiness remains false.

The exporter ID separates independent analytics datasets that share ClickHouse tables. It participates in row keys, deterministic event IDs, purges, projection registration, and metrics. It defaults to the processor client ID. Keep it stable for the lifetime of a dataset; changing it starts a separate ClickHouse row namespace.

All resource kinds and features are enabled by default. Repeat --disable for multiple CLI selectors. Separate multiple MEMORY_SERVICE_CLICKHOUSE_DISABLE selectors with commas.

Selector formEffect
RESOURCEDisable every output for conversations, entries, or memories.
RESOURCE:FEATUREDisable one feature for one resource.
*:FEATUREDisable the feature for every resource that supports it.

The supported feature selectors are:

FeatureValid resourcesEffect
lifecycle_eventsconversations, entries, memoriesDo not write matching rows to lifecycle_events.
lineageconversationsDo not backfill conversation_lineage.
projectionsentries, memoriesDo not create or populate configured projections for the selected resource.

For example, this setting keeps current-state rows but omits all lifecycle events:

MEMORY_SERVICE_CLICKHOUSE_DISABLE=*:lifecycle_events

The processor rejects unknown resources, unknown features, and unsupported combinations such as entries:lineage. A bare resource selector also disables all features for that resource. The common processor schema remains present, so tables for disabled outputs can remain empty. Rows written before an output was disabled remain until a purge or TTL removes them.

Disabling an output can reuse the current checkpoint. Enabling lifecycle, lineage, or a full resource after events were skipped requires a checkpoint and ClickHouse data reset or a new exporter ID. To enable projections again, set a new projection replay ID so the processor scans current entries and memories.

Managed and record-only purge modes continue to consume hard-delete notifications for disabled resources. These notifications remove rows written before the output was disabled without writing new lifecycle or current-state rows. Conversation hard deletes also remove dependent entry analytics. External purge mode subscribes only to enabled resources. At least one resource kind must remain enabled.

Tail-only mode deliberately omits retained history and current-state backfill. Use it only for disposable development data when exporting new events is sufficient. Readiness remains false so monitoring continues to report the durability gap.

Checkpoints

SettingDefaultDescription
--after-cursor MEMORY_SERVICE_PROCESS_AFTER_CURSORstartInitial event cursor when no checkpoint exists.
--checkpoint-interval MEMORY_SERVICE_PROCESS_CHECKPOINT_INTERVAL1sMaximum delay between safe checkpoint saves.
--lease-ttl MEMORY_SERVICE_PROCESS_LEASE_TTL30sExclusive checkpoint lease duration.

ClickHouse connection

SettingDefaultDescription
--clickhouse-address MEMORY_SERVICE_CLICKHOUSE_ADDRESSRequiredRepeatable host:port endpoint.
--clickhouse-protocol MEMORY_SERVICE_CLICKHOUSE_PROTOCOLnativenative or http.
--clickhouse-database MEMORY_SERVICE_CLICKHOUSE_DATABASEmemory_serviceDatabase that contains processor-owned relations.
--clickhouse-username MEMORY_SERVICE_CLICKHOUSE_USERNAMERequiredClickHouse user.
environment only MEMORY_SERVICE_CLICKHOUSE_PASSWORDNoneClickHouse password supplied directly through the environment.
--clickhouse-password-file MEMORY_SERVICE_CLICKHOUSE_PASSWORD_FILENoneFile that contains the ClickHouse password.
--clickhouse-tls MEMORY_SERVICE_CLICKHOUSE_TLSfalseEnable TLS for ClickHouse.
--clickhouse-ca-file MEMORY_SERVICE_CLICKHOUSE_CA_FILENonePEM CA bundle for ClickHouse.
--allow-insecure-clickhouse MEMORY_SERVICE_CLICKHOUSE_ALLOW_INSECUREfalsePermit a non-loopback plaintext connection for development.
--schema-mode MEMORY_SERVICE_CLICKHOUSE_SCHEMA_MODEmanagemanage creates expected objects. validate rejects schema drift without applying DDL.

Schema manage mode enables a 1,000-block insert deduplication window on exporter output and registered projection tables where deduplication is disabled. It preserves existing positive windows and stored data. validate mode rejects a zero window without applying DDL. Both modes need permission to read the server’s default MergeTree settings. For the bundled analytics user, run this grant when upgrading an existing deployment:

GRANT SELECT ON system.merge_tree_settings TO memory_service_analytics;

Insert tokens protect retries within one processor run. After a restart, new batches have new tokens; use canonical views to deduplicate replayed events.

Native TCP commonly uses port 9000 or TLS port 9440. HTTP commonly uses port 8123 or HTTPS port 8443. The repository’s Docker Compose stack maps the ClickHouse native port to localhost:9002 because MinIO uses host port 9000. Containers in that stack continue to use clickhouse:9000.

Configure either the direct password or the password file. The processor rejects configurations that set both.

Payload and metadata

SettingDefaultDescription
--payload-mode MEMORY_SERVICE_CLICKHOUSE_PAYLOAD_MODEmetadatametadata, projected, or full.
--allow-decrypted-content MEMORY_SERVICE_CLICKHOUSE_ALLOW_DECRYPTED_CONTENTfalseRequired for full mode.
--metadata-key MEMORY_SERVICE_CLICKHOUSE_METADATA_KEYNoneRepeatable allowlist entry for conversation metadata.

--metadata-key selects the exact top-level conversation metadata keys that the processor writes to ClickHouse. The admin event stream still sends the complete conversation resource to the processor. Unlisted metadata is discarded before the processor creates ClickHouse rows. This setting does not select entry content or memory values.

The processor stores Memory Service source identifiers directly so an analytics result contains the identifiers needed to retrieve the original resource through the Memory Service API. Treat ClickHouse readers as trusted to see those identifiers. Payload mode and metadata allowlists still control whether content and user-defined metadata cross the analytics boundary.

Projections

SettingDefaultDescription
--projection-path MEMORY_SERVICE_CLICKHOUSE_PROJECTION_PATHNoneProjection YAML file or directory. Repeat the CLI flag or use comma-separated environment values.
--projection-failure-policy MEMORY_SERVICE_CLICKHOUSE_PROJECTION_FAILURE_POLICYcontinue-genericcontinue-generic records the failure. stop stops processing.
--projection-replay-id MEMORY_SERVICE_CLICKHOUSE_PROJECTION_REPLAY_IDNoneNew identifier that requests an explicit entry and memory rescan.

Projection paths are valid only in projected or full mode. A path can identify one YAML file or a directory. For a directory, the processor reads the *.yaml and *.yml files directly inside it; it does not scan subdirectories. YAML documents with another kind are ignored, and at least one kind: AnalyticsProjection resource must be found across all configured paths.

Repeat --projection-path to load multiple paths from the CLI. For MEMORY_SERVICE_CLICKHOUSE_PROJECTION_PATH, separate multiple paths with commas. See Create analytics projections for the manifest format.

To check projection paths before you start the processor, run memory-service process clickhouse-projections with the same --projection-path values or MEMORY_SERVICE_CLICKHOUSE_PROJECTION_PATH. It validates the manifests and prints each table’s chain, combined columns, and which manifest’s logic projects each content type or kind. It doesn’t connect to ClickHouse. Add --format json for machine-readable output.

Batching and retries

SettingDefaultConstraint
--batch-events MEMORY_SERVICE_CLICKHOUSE_BATCH_EVENTS100001 through 100000
--batch-rows MEMORY_SERVICE_CLICKHOUSE_BATCH_ROWS1000001 through 1000000
--batch-bytes MEMORY_SERVICE_CLICKHOUSE_BATCH_BYTES83886081 KiB through 256 MiB
--max-record-bytes MEMORY_SERVICE_CLICKHOUSE_MAX_RECORD_BYTES50331648Maximum encoded size of one record; 1 KiB through 256 MiB
--batch-delay MEMORY_SERVICE_CLICKHOUSE_BATCH_DELAY1sMaximum time before a non-empty batch flushes.
--retry-min MEMORY_SERVICE_CLICKHOUSE_RETRY_MIN1sAt least 100ms.
--retry-max MEMORY_SERVICE_CLICKHOUSE_RETRY_MAX30sMust be greater than or equal to retry-min.

batch-bytes is the aggregate flush target. A single encoded record may exceed that target up to max-record-bytes, in which case the processor writes it as a one-record batch.

The checkpoint advances only after ClickHouse acknowledges every table write in the frozen batch. If the process stops after writing only part of a batch, replay writes the source events again. Stable event and resource keys keep canonical query results logically idempotent.

Retention and deletion

SettingDefaultDescription
--retention-mode MEMORY_SERVICE_CLICKHOUSE_RETENTION_MODEmanagedmanaged or external.
--purge-mode MEMORY_SERVICE_CLICKHOUSE_PURGE_MODEmanagedmanaged, record-only, or external.
--lifecycle-retention MEMORY_SERVICE_CLICKHOUSE_LIFECYCLE_RETENTION0Retention for lifecycle events.
--tombstone-retention MEMORY_SERVICE_CLICKHOUSE_TOMBSTONE_RETENTION0Retention for deletion tombstones.
--generic-payload-retention MEMORY_SERVICE_CLICKHOUSE_GENERIC_PAYLOAD_RETENTION0Retention for active generic rows.
--projection-retention MEMORY_SERVICE_CLICKHOUSE_PROJECTION_RETENTION0Retention for active projection rows.
--projection-failure-retention MEMORY_SERVICE_CLICKHOUSE_PROJECTION_FAILURE_RETENTION0Retention for projection failure rows.

In managed retention mode, the processor owns table TTL expressions and coordinates the database-wide policy through retention_policy. A zero duration leaves that table class without a TTL. When tombstone retention is positive, generic active-row retention must also be positive and cannot exceed tombstone retention. Projection retention follows the same rule when projections are configured.

In external retention mode, the processor does not register a retention owner, validate TTL expressions, or change TTL DDL. Configure all retention durations as 0; the processor rejects nonzero durations in this mode. Existing TTL expressions remain unchanged. Your ClickHouse administration must replace or remove them and retain deletion tombstones for at least as long as older active rows.

Purge modes handle hard-delete events differently:

ModeBehavior
managedWrite purge_queue, resolve purge_subjects, and wait for ClickHouse deletion mutations before advancing the checkpoint.
record-onlyWrite a pending purge_queue request and leave deletion to an external worker.
externalDo not write purge requests or execute deletion mutations. The operator owns hard-delete discovery and removal.

External purge must remove matching generic, typed, lifecycle, projection, projection-failure, and deletion-fence rows. Remove each deletion fence only after its dependent rows. Switching from record-only or external back to managed requires a reset or a new exporter ID because the event checkpoint may have passed unprocessed hard deletes.

deletion_fences remain active in every purge mode. The built-in current-state views depend on them to prevent an older active row from becoming visible after a tombstone expires. The common schema also retains empty purge and retention tables so schema validation stays consistent.

Health

SettingDefaultDescription
--health-address MEMORY_SERVICE_PROCESS_HEALTH_ADDRESS:8081Listener for /healthz, /readyz, and /metrics.

For runtime behavior and failure recovery, see Operate the ClickHouse processor.