Role in the platform
Both Elasticsearch and OpenSearch are supported. The platform driver auto-detects the variant.
Events can also be pushed to Logstash, which forwards them to Elasticsearch or OpenSearch and to your own tools (SIEM, observability platform …).
Version compatibility
- Minimum: Elasticsearch 8.x or OpenSearch 2.x.
- Cluster sharing between environments is supported via index prefixes:
EVENTS_STORAGE_NAMESPACEfor the events store.ELASTIC_INDICES_PREFIXfor crawler and search engine.
Recommended deployment
Sizing: 3-node cluster, 16 GB RAM and 4 vCPU per node minimum, with dedicated master nodes for clusters > 5 data nodes.
Disk: start at ≥ 50 GB per node on a dev environment and ≥ 200 GB per node in production, then grow progressively based on actual usage and retention.
Helm Configuration
Configure your Elasticsearch or OpenSearch cluster credentials in both core & apps helm values :prismeai-crawler and prismeai-searchengine consume ELASTIC_INDICES_PREFIX to namespace their indices when sharing a cluster.
See Helm install for the full install context.
Least privileges
Cluster-level privileges
Only these are required:manage_ilmmanage_index_templatesmonitor
Index-level patterns
The user should only have access to these patterns:${eventsPrefix}-events-*${crawlerPrefix}-searchengine-webpages-*${aikPrefix}*
${eventsPrefix}corresponds to theEVENTS_STORAGE_NAMESPACEenvironment variable onprismeai-events.${crawlerPrefix}corresponds to theELASTIC_INDICES_PREFIXenvironment variable onprismeai-searchengineandprismeai-crawler.${aikPrefix}corresponds to thevector_store_index_prefixkey in the Storage workspace configuration (also visible in Govern > Infrastructure app).
all privilege can reasonably be granted on these three patterns, as the impact is necessarily limited to these three types of data.
Backup & restore
Snapshot API (recommended)
Register an S3 / Azure Blob / GCS snapshot repository, then snapshot regularly.Production targets (RPO / RTO)
Backing up the vector store is far cheaper than rebuilding it: a full re-vectorization costs embeddings plus days of processing.
Updates
- Check index mappings compatibility before a major upgrade.
- Some upgrades require reindexing; plan a maintenance window.
- For OpenSearch users, watch out for driver-specific differences around ILM and snapshot repositories.
Scaling
Index Lifecycle Management (ILM) Policies
Prismeai automatically configures ILM policies to roll indices over when their primary shard reaches 40 GB, as recommended by Elasticsearch or OpenSearch. On Elasticsearch, rolled-over indices are also force-merged. On OpenSearch, the policy only rolls indices over: the ISMforce_merge action leaves indices write-blocked (index.blocks.write), which would break the cleanup jobs below. These jobs also lift index.blocks.write on events indices before running, which unblocks indices rolled over by older versions, including any block set manually.
Our Elasticsearch driver also configures an ILM policy to automate the events deletion 30 days (default, configurable with EVENTS_SCHEDULED_DELETION_DAYS) after workspace deletion.
This is not yet supported by the Opensearch driver, which deletes events as soon as the workspace is deleted.
Events expiration is not configured from ILM as they do not offer the precision needed to tune different expiration periods depending on the different kind of data.
Instead, events expiration is enforced by prismeai-events /sys/cleanup/* APIs which are automatically called from a Kubernetes CronJob as described below.
Events automated cleanup
In addition to ILM, we provide a lightweight Kubernetes-native cleaner service that automatically:- Deletes expired events to enforce data retention regulation (i.e GDPR).
- Deletes datastreams from small & inactive workspaces to reduce shards usage and avoid reaching the 1000 shards per node limit.
- Removes
payloadandoutputfields fromruntime.automations.executedtechnical events to save disk space without compromising audit/debug capabilities in short term.
cleanup-es-indices Kubernetes CronJob scheduled every sunday at 0AM, while step 3 is executed from a cleanup-exec-events CronJob every night at 3:30AM.
Troubleshooting cleanup jobs
- Create a manual cleanup job from the existing CronJob:
- Check the job logs:
- Retrieve the task ID from the logs (e.g.
a3H0dnU3Sc2s66rwbmtCiQ:25814043above) and check its status with an Elasticsearch request:
- Key output fields:
- completed: Whether the cleanup task is still running or not. If it is, wait and regularly check its status again.
- task.running_time_in_nanos: Execution time.
- response.failures: Errors.
- response.total: Number of documents matching the query.
- response.updated: Number of documents updated by the query (removing all big data without removing the event itself to keep metadata).
- task.description: Request description.
Optimize index settings
- Scale your search cluster by adding more nodes and optimizing node roles. Configure dedicated master nodes for cluster management and data nodes for storage and search operations.
- Optimize index settings including primary shard count, replica count, and refresh intervals based on your data volume and query patterns.
- Implement Index Lifecycle Management (ILM) policies to automatically manage index aging, including hot, warm, cold, and delete phases.
- Retrieve your Knowledges (or other) index template configuration:
- Keep it, adjust existing configuration as needed and add the last template settings:
index.number_of_shards to 2 if you only have 2 nodes.
index.refresh_interval configures how often Elasticsearch will make your freshly written data available for search.
- Rollover your datastream in order to create a new index with the updated template:
Elasticsearch Self-Hosted Considerations
When running a self-hosted Elasticsearch or OpenSearch cluster, ensure nodes are distributed across different physical machines for proper redundancy. Use high-performance disks and monitor CPU iowait metrics to identify potential disk bottlenecks that could impact search performance. Pay attention to cluster health metrics and ensure adequate disk space for index growth and operations like merging and replication.Shard accounting
Elasticsearch and OpenSearch limit each data node to 1000 shards by default, primaries and replicas included. A 3-node cluster can therefore hold at most 3000 shards. At the limit, the cluster refuses every new index, whichever service asks for it: see When the cluster reaches the shard limit. The monitoring thresholds alert you well before. Three kinds of data create indices, and therefore consume shards (prefixes as in Index-level patterns):- Events: one data stream per workspace,
${eventsPrefix}-events-<workspaceId>on Elasticsearch orevents-${eventsPrefix}-<workspaceId>on OpenSearch. Each rollover adds a backing index. The events automated cleanup CronJob frees shards by deleting the data streams of small, inactive workspaces, and a deleted workspace’s events are deleted with it (see ILM above). - Knowledge bases: one index per knowledge base,
${aikPrefix}_vs_<id>, orvs_<id>when no prefix is set. Each one takes 2 shards (1 primary, 1 replica), whatever its size. This includes the conversation knowledge base an agent creates the first time a file is attached in one of its conversations. These shards are freed only when the knowledge base, its agent or its owner is deleted: no CronJob removes them. A platform with many small knowledge bases reaches the shard limit long before its disk limit. - Crawler and search engine: the web pages indexed by
prismeai-crawlerforprismeai-searchengine, in${crawlerPrefix}-searchengine-webpages-*.
/sys/events/* route that returns the ES/OS _cat/shards as JSON. It is reserved to super admins (email in SUPER_ADMIN_EMAILS), and the gateway forwards to the events service sys/* APIs, so you can call it from outside the cluster:
?group=true to aggregate the shards by tenant (client) and by index-pattern family :
.ds-events, searchengine-webpages, aik_rag, type prefix). Optional query params:
patterns: comma-separated pattern templates (with%sas the tenant placeholder) to override the defaults above.tenants: comma-separated tenant list to force grouping (like theTENANTSvariable in the script) when auto-detection isn’t enough.index: restrict the underlying_cat/shardscall to a given index/pattern. For instance,index=*vs_*counts the shards of knowledge bases alone, 2 per knowledge base.
When the cluster reaches the shard limit
Symptom. Index creation fails with this error (the numbers depend on your cluster):- In Agent Creator, a file attached to a conversation is marked as not indexed because the platform has temporarily reached its capacity, when the agent has no conversation knowledge base yet. The agent tells the user to try again later. The full error is in the
ConversationKnowledgeBaseUnavailableerror event, in the Activity of theagent-factoryworkspace. Agents that already have one are not affected. - In Knowledge, creating a knowledge base fails with a message saying the platform has temporarily reached its capacity. The API answers
507with the codeCAPACITY_EXCEEDED. The full engine error is in theVectorIndexCreationFailederror event, in the Activity of thestorageworkspace. - New events data streams and their rollovers are refused as well.
- Find what consumes the shards with
/sys/events/shards?group=true, then/sys/events/shards?index=*vs_*for knowledge bases (see above). - Free shards:
- Events: check that the cleanup CronJob is enabled (
events.cleanupjob: true), then run it once by hand as described in Troubleshooting cleanup jobs. - Knowledge bases: delete the knowledge bases, and the agents, that are no longer used. Deleting a knowledge base deletes its index and frees its 2 shards.
- Events: check that the cleanup CronJob is enabled (
- If the remaining data still needs more shards, add data nodes: each one adds 1000 shards with the default limit. On Amazon OpenSearch Service 2.17 and later, AWS sets the limit to 1000 shards per 16 GB of JVM heap, up to 4000 per node: add nodes or use larger instances.
/sys/events/shards reports a total below the limit, and attaching a file to an agent that has never received one succeeds.
Move an Elasticsearch node without losing redundancy
When you need to migrate an Elasticsearch node to a different Kubernetes node without ever dropping below the original replica count (so shards keep two live copies at all times):- Provision the new Kubernetes node.
- Increase the Elasticsearch
nodeSet.replicasby one (e.g.kubectl -n <ns> edit elasticsearch/core). - Wait for shards to rebalance onto the new ES node (
GET /_cat/allocation/?v; relocating shards should drop to 0 for a few minutes). - Drain the Kubernetes node you want to retire (
kubectl drain node/<name>). The old ES pod terminates and shards relocate to the remaining nodes. - The StatefulSet will try to recreate the missing pod elsewhere; it will stay
Pendingbecause no node has the resources requested. - Decrease the Elasticsearch
nodeSet.replicasback to the original count. ThePendingpod is removed cleanly without disturbing the running ones. - Delete the drained Kubernetes node.
Operations & Troubleshooting
Volume formatting
When formatting the Elasticsearch or OpenSearch filesystem volume, it is important to first shutdown theprismeai-events microservice in core namespace. This can be easily done from Kubernetes by editing the deployment and setting replicas: 0.
Index mappings are initialized when prismeai-events starts up. If indexes and index mappings are deleted (such as when formatting a volume) without first stopping prismeai-events, the next event persistence request sent to the cluster would cause it to automatically infer an incorrect index mapping, which would cause most other persistence requests to fail and result in data loss. This is because when Prisme.ai events mapping are not initialized before first events write requests, ES/OS automatically infer mappings for payload.* nested fields, making it incompatible with the needed flattened (ES) / flat_object (OS) mapping on the entire payload field.
This situation causes errors like Limit of total fields [1000] has been exceeded as ES/OS tries to map every single payload.* nested field until reaching the 1000 fields maximum limit.
If it is possible to delete the events data (includes workspaces debug events and AIK usage metrics), this can be easily solved by:
- Shutting down
prismeai-eventsby editing the deployment and settingreplicas: 0. If a HorizontalPodAutoscaler exists forprismeai-events, first delete it or set its min/max replicas to 0. - Removing every failed index/datastream either from Kibana or curl:
_index field of prismeai-events error logs.
Names starting with .ds-events- are datastreams underlying indexes and can be renamed like this to delete all underlying indexes at once: .ds-events-<id>-000001 -> events-<id>
- Restarting
prismeai-eventsby editing the deployment and settingreplicas: 1
Fix the mapping of events indices
The fields an event schema declares (events.types.<type>.schema in a workspace index.yml) are mapped under aggPayload when the schema is saved. If the events indices of a workspace miss these fields (schema never applied, mapping update rejected by an older version), aggregations on them return nothing, without error, although the values are stored in the events. Typical symptom: AI Insights shows no statistics, or zeros, for an organization whose agents are used.
Two procedures exist. Start with the reconciliation: it is enough whenever fields are missing, which is the case of empty analytics.
Reconcile events mappings
The events service can realign the events indices of a workspace with the schema its DSUL declares, and reindex the events stored before their fields were mapped. Through the api-gateway, as a super admin:events container, the same routes are served under /sys/mappings/* with x-prismeai-api-key: $INTERNAL_API_KEY.
The response gives:
added: the fields each backing index did not map yet;writeIndexConflicts: the fields the write index already maps with another type. Elasticsearch / Opensearch cannot change a field type in place;olderIndicesConflicts: the same on older indices, for information only. They keep their mapping until their retention ends, and are reported again on every call;rolloverNeeded:truewhen the write index cannot get every expected field in place, because it maps one with another type or because a conflicting field is left out for every index. The data stream is then rolled over (rolledOver: true), so that new events get the expected mapping;reindex.task: the reindexing task, an in-place_update_by_queryof the events of each schema type where one of the fields of that type is not indexed yet. Events indexed since the mapping update are left out, so a rerun only rewrites what is left, except the events without a value for an optional field, which are taken on every call. Fields declared in a rawevents.mappingare mapped but do not select events. A task already running on the same data stream is returned (alreadyRunning) instead of starting another one.writeBlockedlists the indices whose write block, set by the ILM force merge, was lifted for it. In dry run,toReindexgives the number of events the task would rewrite, to chooserequestsPerSecondbefore starting it;status:skippedwithreason: NoEventSchemafor a workspace without event schema. An unknown workspace answers 404.
response.failures. An event whose value does not fit its field type stops the task there; fix or delete that event, or change the schema, then call the endpoint again with reindex=true.
On Elasticsearch, the indices whose write block was lifted stay writable. The data stream only writes to its write index, but to set the block back once the task is completed:
INTERNAL_API_KEY: WORKSPACES_API_URL must then be set on prismeai-events.
AI Insights figures read live from the events (overview totals) show up once the reindexing task is completed. Its daily statistics (consumption, activity charts) are stored per day and not recomputed: rebuild the affected period by running the
jobs/backfill-org-analytics automation of the AI Insights workspace from the builder, with { "orgSlug": "<org>", "from": "<first day>", "to": "<day after the last one>" }.Reindexing events with default mapping
This procedure rewrites a whole data stream. For missing fields, Reconcile events mappings is enough and safer: use this one only to change the type of a field already mapped, or to drop events. Follow these steps in order to reindex a workspace events datastream with the default index settings & mappings initialized (or updated) byprismeai-events:
- Find the correct name for the datastream you want to reindex and make sure it exists:
- List existing index templates and make sure an index template exists for your
events-*pattern:
Some workspaces like Knowledges have a custom specific index template tuned for their needs, with the workspace id included in their index & component template name.
composed_of) to all indices matching index_patterns.
The component template is where Prisme.ai custom index settings & mappings are configured.
- Create a temporary datastream:
index_patterns seen above so this new datastream will inherit default index settings & mappings.
- Reindex your data from the current to the temporary & remapped datastream:
"conflicts": "proceed" option to the body in order to ignore documents already created in destination index.
A response with {"failures": []} indicates all data have been reindexed & match the destination mapping.
In case of a mismatch between source data and destination mapping, you can receive error response like this:
- Delete the current datastream:
- Clone our temporary datastream to the “current” datastream exactly like we previously did the other way around:
hits.total.value: the number of matching documentsaggregations.latestDate.value_as_string: the latest matching document dateaggregations.oldestDate.value_as_string: the oldest matching document date
- Check from your browser that the target workspace events feed is not empty and contains old data, and that events previously failing to persist are now persisted. If everything is fine, you can delete the temporary datastream: