Skip to main content

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_NAMESPACE for the events store.
    • ELASTIC_INDICES_PREFIX for crawler and search engine.
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_ilm
  • manage_index_templates
  • monitor

Index-level patterns

The user should only have access to these patterns:
  • ${eventsPrefix}-events-*
  • ${crawlerPrefix}-searchengine-webpages-*
  • ${aikPrefix}*
Where:
  • ${eventsPrefix} corresponds to the EVENTS_STORAGE_NAMESPACE environment variable on prismeai-events.
  • ${crawlerPrefix} corresponds to the ELASTIC_INDICES_PREFIX environment variable on prismeai-searchengine and prismeai-crawler.
  • ${aikPrefix} corresponds to the vector_store_index_prefix key in the Storage workspace configuration (also visible in Govern > Infrastructure app).
The all privilege can reasonably be granted on these three patterns, as the impact is necessarily limited to these three types of data.

Backup & restore

Register an S3 / Azure Blob / GCS snapshot repository, then snapshot regularly.
Operational strategy (RPO/RTO, retention) lives in Operations / Backup.

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.
Full requirements and the go/no-go checklist are in Production Readiness.

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.
See Operations / Updates.

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 ISM force_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:
  1. Deletes expired events to enforce data retention regulation (i.e GDPR).
  2. Deletes datastreams from small & inactive workspaces to reduce shards usage and avoid reaching the 1000 shards per node limit.
  3. Removes payload and output fields from runtime.automations.executed technical events to save disk space without compromising audit/debug capabilities in short term.
These 3 tasks are configurable from helm values:
Step 1 and 2 are executed from a 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

  1. Create a manual cleanup job from the existing CronJob:
  1. Check the job logs:
Example logs:
  1. Retrieve the task ID from the logs (e.g. a3H0dnU3Sc2s66rwbmtCiQ:25814043 above) and check its status with an Elasticsearch request:
Example curl from the events container:
  1. 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.
Here’s a typical configuration to apply to an index (or datastream, as for Knowledges) to improve write performance:
  1. Retrieve your Knowledges (or other) index template configuration:
  1. Keep it, adjust existing configuration as needed and add the last template settings:
Here, we configure the index template with 3 primary shards and 1 replica per primary, allowing you to distribute write traffic to all of your 3 nodes. Decrease 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.
  1. 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 or events-${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>, or vs_<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-crawler for prismeai-searchengine, in ${crawlerPrefix}-searchengine-webpages-*.
In order to troubleshoot what patterns / apps consume the most shards, the api-gateway exposes a /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:
The same route is served directly by the events service under /sys/shards (without the /sys/events gateway prefix), if you’d rather call it from inside the events container: curl -H "x-prismeai-api-key: $INTERNAL_API_KEY" http://localhost:80/sys/shards.
It answers with the shard count and the raw shard list:
Add ?group=true to aggregate the shards by tenant (client) and by index-pattern family :
Tenants are auto-detected from index names. When they can’t be resolved (e.g. workspace-id datastreams), shards fall back to tenant-free prefix groups (.ds-events, searchengine-webpages, aik_rag, type prefix). Optional query params:
  • patterns: comma-separated pattern templates (with %s as the tenant placeholder) to override the defaults above.
  • tenants: comma-separated tenant list to force grouping (like the TENANTS variable in the script) when auto-detection isn’t enough.
  • index: restrict the underlying _cat/shards call 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 Prisme.ai, it shows up as follows:
  • 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 ConversationKnowledgeBaseUnavailable error event, in the Activity of the agent-factory workspace. 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 507 with the code CAPACITY_EXCEEDED. The full engine error is in the VectorIndexCreationFailed error event, in the Activity of the storage workspace.
  • New events data streams and their rollovers are refused as well.
Existing knowledge bases keep working: their indices already exist. Cause. The cluster holds as many shards as its data nodes allow. Resolution. You need super admin access to the API and access to the cluster.
  1. Find what consumes the shards with /sys/events/shards?group=true, then /sys/events/shards?index=*vs_* for knowledge bases (see above).
  2. 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.
  3. 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.
Verification. /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):
  1. Provision the new Kubernetes node.
  2. Increase the Elasticsearch nodeSet.replicas by one (e.g. kubectl -n <ns> edit elasticsearch/core).
  3. Wait for shards to rebalance onto the new ES node (GET /_cat/allocation/?v; relocating shards should drop to 0 for a few minutes).
  4. Drain the Kubernetes node you want to retire (kubectl drain node/<name>). The old ES pod terminates and shards relocate to the remaining nodes.
  5. The StatefulSet will try to recreate the missing pod elsewhere; it will stay Pending because no node has the resources requested.
  6. Decrease the Elasticsearch nodeSet.replicas back to the original count. The Pending pod is removed cleanly without disturbing the running ones.
  7. Delete the drained Kubernetes node.
Relocating shards takes hours on a large cluster (ES processes them two at a time). If you don’t need zero-downtime relocation, the simpler path is to delete the target node first and let the cluster rebalance with one fewer node, at the cost of a short window where some shards run on a single replica.

Operations & Troubleshooting

Volume formatting

When formatting the Elasticsearch or OpenSearch filesystem volume, it is important to first shutdown the prismeai-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:
  1. Shutting down prismeai-events by editing the deployment and setting replicas: 0. If a HorizontalPodAutoscaler exists for prismeai-events, first delete it or set its min/max replicas to 0.
  2. Removing every failed index/datastream either from Kibana or curl:
Failed index names can be found in _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>
  1. Restarting prismeai-events by editing the deployment and setting replicas: 1
If events data cannot be lost, the existing indexes must be manually reindexed with the appropriate mapping.

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:
From inside the 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: true when 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_query of 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 raw events.mapping are mapped but do not select events. A task already running on the same data stream is returned (alreadyRunning) instead of starting another one. writeBlocked lists the indices whose write block, set by the ILM force merge, was lifted for it. In dry run, toReindex gives the number of events the task would rewrite, to choose requestsPerSecond before starting it;
  • status: skipped with reason: NoEventSchema for a workspace without event schema. An unknown workspace answers 404.
Follow the reindexing tasks:
When the task completes, check its 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:
When the call also rolled the data stream over, ILM may force merge the previous write index, and block it, while the task runs. The task then reports failures on that index: call the endpoint again, it only reindexes what is left. The schemas are read from the workspaces API with the caller’s token, or, without one, directly from the workspaces service with 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>" }.
To change the type of a field already mapped, follow the procedure below instead.

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) by prismeai-events:
  1. Find the correct name for the datastream you want to reindex and make sure it exists:
  1. List existing index templates and make sure an index template exists for your events-* pattern:
Example:
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.
This index template automatically applies its configuration and component templates (composed_of) to all indices matching index_patterns. The component template is where Prisme.ai custom index settings & mappings are configured.
  1. Create a temporary datastream:
Make sure your temporary index name matches the index_patterns seen above so this new datastream will inherit default index settings & mappings.
  1. Reindex your data from the current to the temporary & remapped datastream:
You can optionally add a query filter to the source, very useful if you want to drop all error & execution events (which can take lot of disk space & are only useful for debugging last few days activities):
When retrying this request multiple times (for example with different source query to drop documents incompatible with the new mapping), you can add an "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:
Either adapt the destination mapping or filter out these documents using the source query.
  1. Delete the current datastream:
  1. Clone our temporary datastream to the “current” datastream exactly like we previously did the other way around:
Make sure the response failures is an empty [] and total is the same as the first _reindex total.
Optionally, check that some specific type of event has been recovered:
Example response:
  • hits.total.value: the number of matching documents
  • aggregations.latestDate.value_as_string: the latest matching document date
  • aggregations.oldestDate.value_as_string: the oldest matching document date
  1. 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: