Event-Driven Architecture (EDA)
Event-driven architecture is the foundation of AI Builder’s flexibility:
- Events as First-Class Citizens: All system and user actions generate events
- Decoupled Components: Services communicate through events, not direct calls
- Asynchronous Processing: Actions occur independently of event producers
- Scalability: Components can scale independently based on event load
- Extensibility: New capabilities can subscribe to existing event streams
- An event type (e.g.,
message.created
,user.login
) - A payload with event-specific data
- Metadata about the source, timestamp, and routing information
Working with Events
1
Emitting Events
In automations, you can emit events to trigger other processes:Blocks can also emit events when users interact with them:These events flow through the system and can trigger other automations or be recorded for analysis.
2
Listening for Events
Automations can be triggered by specific events:This creates a chain of actions that can flow through your application, each step triggered by the completion of previous steps.
3
Accessing Event History
View event history in several ways:
- Activity Tab: See recent events in your workspace
- Event Explorer: Query and filter events for analysis
- Elasticsearch/OpenSearch: Advanced querying for deeper analysis
4
Analyzing Event Patterns
Advanced analytics can reveal important patterns:
- User Journeys: Track how users move through your application
- Bottlenecks: Identify where processes slow down
- Error Patterns: Detect recurring issues
- Usage Trends: See how usage evolves over time
- Feature Adoption: Measure which features are most used
Advanced Event Analytics
Every event in your workspace is stored in Elasticsearch/OpenSearch, enabling custom analysis:System Mapping
Create visual maps of your systems based on actual usage:
- Track event flows between componentsVisualize user journeys through your applicationIdentify unused features or dead-end pathsDiscover unexpected usage patternsMap integration points with external systems
Usage Analytics
Understand how users engage with your applications:
- Measure feature adoption and frequency of useTrack user session patterns and durationIdentify popular and underutilized featuresAnalyze conversion funnels and drop-off pointsSegment users by behavior patterns
Performance Monitoring
Track system performance metrics:
- Measure response times for different operationsIdentify bottlenecks in processing flowsTrack API usage and latencyMonitor automation execution timesAnalyze resource utilization patterns
Pattern Discovery
Find meaningful patterns in your event data:
- Discover common user behavior sequencesIdentify correlations between eventsDetect anomalies that may indicate issuesRecognize seasonal or time-based patternsFind optimization opportunities
Event Mapping for Analytics
Introduction to Event Mapping
Introduction to Event Mapping
As part of Prisme.ai’s event-driven architecture, we process events structured with a dynamic identifier
payload
. To ensure consistent and efficient aggregation in both Elasticsearch and OpenSearch, it’s essential to explicitly define the mapping for fields used in the payload.Without proper mapping, you may encounter issues such as:- Aggregation inconsistencies between Elasticsearch and OpenSearch
- Fields interpreted with incorrect data types
- Performance issues with complex queries
- Limitations in available analysis capabilities
Benefits of Explicit Mapping
Benefits of Explicit Mapping
Reliability and Consistency
Ensures uniform data treatment:
- Consistent field types across all eventsPrevents errors caused by automatic inferenceGuarantees that aggregations work properlyMaintains data integrity over time
Performance Optimization
Improves query and analysis speed:
- Optimizes indexing for known data structuresEnables more efficient storage patternsImproves complex aggregation performanceReduces processing overhead for queries
Maintenance and Scalability
Simplifies ongoing management:
- Easy-to-read YAML configurationWorkspace-specific mapping definitionsSimplified schema evolutionBetter documentation of data structures
Cross-Platform Compatibility
Works consistently across search engines:
- Identical behavior in Elasticsearch and OpenSearchConsistent query results across environmentsReliable migrations between search technologiesFuture-proof for search engine updates
Implementing Event Mapping
Implementing Event Mapping
To implement explicit event mapping, add configuration to your workspace YAML:When implementing:
This example defines the schema for the
usage
event type, specifying that fields like usage.total_tokens
and usage.cost
should be treated as numeric values with specific formats.- Identify the event types requiring explicit mapping
- Define their schema with appropriate data types
- Add the configuration to your Workspace
- Emit sample events
- Test with analytical queries to verify proper behavior
When declaring a new field inside events mapping, ES/OS should take it into account for any upcoming event.
When updating an existing field inside events mapping, the ES/OS index must be rollover’ed to take it into account for future events.
Advanced Usage Analytics Example
Advanced Usage Analytics Example
Here’s how you might use mapped events for advanced analytics:With proper mapping, these aggregations will be fast and accurate, providing valuable insights into application usage and performance.
Note our aggregation needs to target aggPayload.* to benefit from our custom mapping
Practical Event-Driven Patterns
User Activity Tracking
User Activity Tracking
Track and analyze user behavior:These events can be analyzed to:
- Create user journey maps
- Identify popular features
- Measure engagement
- Detect unusual behavior
- Personalize experiences based on usage patterns
AI Model Performance Tracking
AI Model Performance Tracking
Monitor and optimize AI model usage:This data enables:
- Cost tracking and optimization
- Performance benchmarking
- Model selection refinement
- Usage pattern analysis
- Identifying optimization opportunities
Multi-Step Workflows
Multi-Step Workflows
Implement complex business processes through event chains:This approach creates modular, maintainable workflows that are:
- Easily extendable with new steps
- Resilient to failures (steps can be retried individually)
- Transparent (full visibility into process state)
- Analyzable (measure performance of each step)