Configuration And Secrets
Canonical runtime env vars:
MONGODB_URIorMONGO_URIMONGODB_URI_SECRET_NAMEKEY_VAULT_URLCRM_EVENTS_REDIS_ENABLEDCRM_EVENTS_REDIS_URLCRM_EVENTS_REDIS_URL_SECRET_NAMECRM_EVENTS_REDIS_HOSTCRM_EVENTS_REDIS_HOST_SECRET_NAMECRM_EVENTS_REDIS_PASSWORDCRM_EVENTS_REDIS_PASSWORD_SECRET_NAMECRM_EVENTS_REDIS_DBCRM_EVENTS_API_PORTCRM_EVENTS_API_CORS_ORIGINSCRM_EVENTS_API_REQUIRE_DOCS_PROXY_BEARER_TOKENCRM_EVENTS_API_BEARER_TOKENCRM_EVENTS_CACHE_ENABLEDCRM_EVENTS_CACHE_OVERVIEW_TTL_SECONDSCRM_EVENTS_CACHE_CAMPAIGNS_TTL_SECONDSCRM_EVENTS_CACHE_LIVE_EVENTS_TTL_SECONDS
mongodb.* controls the Mongo connection that crm_events uses:
mongodb.urimongodb.uri_secret_namemongodb.read_timeout_ms
redis.* controls the shared read-through cache:
redis.enabledredis.urlredis.url_secret_nameredis.hostredis.host_secret_nameredis.passwordredis.password_secret_nameredis.db
The owned local database name is fixed to crm_events.
The HTTP API reads only local collections from that database:
campaign_snapshotscampaign_activity_eventssupport_case_eventslive_eventssync_state
crm_events run starts automatic background jobs that refresh the campaign and
overview slices hourly, and the live-events slice minutely. Tenants are
enumerated from Content.config.
The background jobs still read fixed upstream Mongo databases in code:
CRM, notify, notify_triggers, NotificationService, spark_bonus,
Lumio, and Content.
CRM_EVENTS_API_CORS_ORIGINS is a comma-separated allowlist of browser origins.
When it is unset and api.cors_origins is empty in YAML, the API only allows
loopback browser origins such as http://localhost:3000.
CRM_EVENTS_API_REQUIRE_DOCS_PROXY_BEARER_TOKEN defaults to false. Set it to
true when requests marked by the docs UI proxy should require bearer auth
while unmarked in-cluster requests remain unauthenticated.
When this is enabled, both docs-ui-svc and crm-events-svc read
CRM_EVENTS_API_BEARER_TOKEN from the Kubernetes Secret crm-events-svc.
The secret must expose that exact key name.
CRM_EVENTS_REDIS_ENABLED defaults to true. When it is false, crm_events
does not cache reads at all.
Redis resolution prefers CRM_EVENTS_REDIS_URL, then
CRM_EVENTS_REDIS_URL_SECRET_NAME, then host/password inputs where literal
values beat the corresponding *_SECRET_NAME values and
CRM_EVENTS_REDIS_DB supplies the DB suffix when needed. Any secret-name path
requires KEY_VAULT_URL.
When Redis caching is enabled:
- Mongo remains the source of truth
- Redis failures fall back to Mongo reads
- overview and campaigns default to a 1 hour payload TTL
- live events default to a 60 second payload TTL
- campaign list requests with a non-empty
searchfilter bypass Redis payload caching
For spark-dev1, crm_events is configured with:
- direct public ingress disabled
- docs UI proxy at
https://docs.spark-test.newtoncelestial.com/api/crm-events - in-cluster service URL
http://crm-events-svc.spark-ai.svc.cluster.local - browser CORS allowlist entries for:
https://owners-hub.spark-test.newtoncelestial.comhttps://docs.spark-test.newtoncelestial.com
- docs UI proxy bearer auth enabled
docs-ui-svcandcrm-events-svcloadCRM_EVENTS_API_BEARER_TOKENfrom the Kubernetes Secretcrm-events-svc
For spark-prod-mexico1, crm_events is configured with:
- public ingress at
crm-events.prod-na-01.nwt-spark.net - docs UI proxy at
https://docs.prod-na-01.nwt-spark.net/api/crm-events - in-cluster service URL
http://crm-events-svc.spark-ai.svc.cluster.local - browser CORS allowlist entries for:
https://docs.prod-na-01.nwt-spark.nethttps://dashboard.prod-na-01.nwt-spark.nethttps://dashboard.prod-oh.newtoncelestial.com
- docs UI proxy bearer auth enabled
docs-ui-svcandcrm-events-svcloadCRM_EVENTS_API_BEARER_TOKENfrom the Kubernetes Secretcrm-events-svc
The service supports Azure Key Vault resolution for:
- Mongo URI
- Redis URL
- Redis host and password
If a *_SECRET_NAME value is set, KEY_VAULT_URL must also be set.
Response metadata
Every successful read response includes additive meta.sync metadata with:
tenant_idslicestatuslast_success_atfresh_untilis_stalelag_secondsfor live-events slices
status is currently healthy, missing, or failed. is_stale becomes
true when the slice is not healthy or its freshness window has elapsed.
Every response also includes X-Request-Id. Clients can supply that header on
the request to preserve an upstream trace id, or read the generated value from
the response for log correlation.
Prometheus metrics
/metrics exposes per-tenant, per-slice gauges derived from sync_state:
crm_events_sync_last_success_age_secondscrm_events_sync_fresh_until_age_secondscrm_events_sync_lag_secondscrm_events_sync_failure_count
Each metric uses tenant_id and slice labels, where slice is one of
overview, campaigns, or live_events.
crm_events_sync_failure_count is the consecutive failure count since the last
successful sync for that tenant and slice. crm_events_sync_fresh_until_age_seconds
is negative while the slice is still within its freshness window and becomes
positive once the slice is stale.
Local compose defaults
Local compose expects the shared notify_triggers_notify-local Docker network
and points Mongo at shared-mongo:27017 plus Redis at v2-redis:6379.
The service still writes and reads its owned crm_events database on that
server. A fresh local read model starts empty until crm_events run
bootstraps tenants from Content.config.
Default ports:
- API:
8086 - Health:
8086