Why using Analytics?For more information on Analytics and its benefits, see the
Analytics product documentation.
Types of metrics
With the Analytics pipeline, measurement of the following metrics is possibleDatabase Indexes
New in 3.7.0Rasa Pro Services 3.7.0 introduces new database indexes to improve the performance of Analytics queries during event processing.
- A composite index on the
session_idandtimestamp ASCcolumns of therasa_eventtable; - A composite index on the
sender_id,session_idandtimestamp ASCcolumns of therasa_eventtable; - A composite index on the
sender_idandsequence_numbercolumns of therasa_eventtable; - An index on the
sender_keycolumn of therasa_sendertable; - A composite index on the
sender_idandstart_sequence_number DESCcolumns of therasa_sessiontable; - A composite index on the
sender_id,session_idandstart_sequence_number DESCcolumns of therasa_turntable; - A composite index on the
sender_id,session_idandstart_sequence_number DESCcolumns of therasa_dialogue_stack_frametable;
Prerequisites
- A production deployment of Kafka is required to set up Rasa. We recommend using Amazon Managed Streaming for Apache Kafka.
- A production deployment of PostgreSQL needs to be connected to the data pipeline. Rasa directly supports PostgreSQL as the analytics database (Amazon RDS PostgreSQL is recommended; all PostgreSQL >= 11.0 are supported). Other data warehouses can be used by syncing from your PostgreSQL deployment. You can find instructions on how to stream data to Redshift, BigQuery, or Snowflake in the Connect a data warehouse step. We recommend managed deployments of your data warehouse to minimize maintenance efforts.
1. Connect an assistant
To connect an assistant to Rasa Pro Services, you need to connect the assistant to an event broker. The assistant will stream all events to the event broker, which will then be consumed by Rasa Pro Services.How to consume events from Rasa
To check how to configure Rasa to publish events to Kafka, please refer to the Rasa event broker documentation.Configuration
New in Rasa Pro Services 3.6Rasa Pro Services 3.6 introduces new configuration environment variables to support IAM authentication to AWS RDS MSK:
IAM_CLOUD_PROVIDERAWS_DEFAULT_REGION
KAFKA_SSL_CERTFILE_LOCATIONKAFKA_SSL_KEYFILE_LOCATION
With versions 3.5.4 and 3.4.3. Rasa Analytics introduced new configuration options:
KAFKA_SOCKET_KEEP_ALIVE_ENABLED,
KAFKA_METADATA_MAX_AGE_MS
KAFKA_PRODUCER_RETRIES,
KAFKA_PRODUCER_TIMEOUT_MS,
KAFKA_PRODUCER_PARTITIONER,
KAFKA_COMPRESSION_CODEC,
KAFKA_CONSUMER_HEARTBEAT_INTERVAL_MS,
KAFKA_CONSUMER_SESSION_TIMEOUT_MS,
KAFKA_CONSUMER_MAX_POLL_INTERVAL_MS,
MAX_MESSAGES_TO_FETCH,
RETRY_CONNECTION_COUNT and
RETRY_DB_TRANSACTION_COUNT.
To learn more about dead letter queues, please refer to the
Wikipedia article.
During the development phase, Rasa Analytics can be started before event topic is created.
The topic can be created later on. Rasa Analytics will poll the topic
for new events. If the topic is not created, Rasa Analytics will not consume any events.
Dead letter queue is not required for Rasa Analytics to work. It is only used to store events that could not be processed by Rasa Analytics.
In production environment, we recommend that the event topic and dead letter topic are created before starting Rasa Analytics.
Mapping between Rasa Analytics and Confluent Kafka configuration
The following table shows the mapping between Rasa Analytics environment variables and Confluent Kafka configuration propertiesAzure Event Hubs
Rasa Analytics can also be connected to Azure Event Hubs. Microsoft recommends certain configuration settings are set to ensure optimal performance and connection stability.Example Configurations
Without authentication
To set up Rasa Analytics with Kafka which does not require authentication nor TLS handshake, use the following config as an example:With authentication
To set up Rasa Analytics with Kafka which does require authentication but does not use TLS handshake, use the following config as an example:GSSAPI, OAUTHBEARER, SCRAM-SHA-256 or SCRAM-SHA-512 if your broker is configured to use it for the
exposed URL endpoint.
(Optional) Using IAM roles to authenticate to AWS RDS (PostgreSQL) and MSK
New in Rasa-Pro-Services 3.6You can use IAM authentication to connect to AWS RDS (PostgreSQL) and MSK without needing to provide static credentials.
- your RDS database is configured to allow IAM authentication. Once your RDS instance is up, connect to it and run the following SQL command to enable IAM authentication for the database user you want to use:
- your MSK cluster is configured to allow IAM authentication.
- ensure that the topic you want to use is created on the MSK cluster.
IAM_CLOUD_PROVIDER: Set this toawsto enable IAM authentication.AWS_DEFAULT_REGION: Set this to the AWS region where your RDS database and MSK cluster are located.RASA_ANALYTICS_DB_SSL_MODE: the SSL mode to use when connecting to the database, e.g.verify-fullorverify-caRASA_ANALYTICS_DB_SSL_CA_LOCATION: the path to the SSL root certificate to use when connecting to the database. This can be downloaded for the particular region from here.KAFKA_SECURITY_PROTOCOL: Set this toSASL_SSLto use SASL over SSL.KAFKA_SASL_MECHANISM: Set this toOAUTHBEARERto use IAM authentication.KAFKA_SSL_CA_LOCATION: the path to the SSL root certificate to use when connecting to MSK. This can be downloaded from Amazon Trust Services.
Kubernetes deployment
The configuration of the assistant is the first step of Installation and Configuration. No additional configuration is required to connect the assistant to the Analytics pipeline. After the assistant is deployed, the Analytics pipeline will receive the data from the assistant and persist it to your data warehouse which will be configured in the next step.2. Connect a data warehouse
Configure the analytics pipeline to stream the transformed conversational data to a PostgreSQL database. This is the only data warehouse type that Rasa directly supports. If you prefer a different data warehouse, you can sync from your PostgreSQL deployment. We have included brief instructions for syncing with:PostgreSQL
You can use Amazon Relational Database Service (RDS) to create a PostgreSQL DB instance which is the environment that will run your PostgreSQL database. First, you must set up Amazon RDS by completing the instructions listed here. Next, create the PostgreSQL DB instance. You can follow one of the following instruction sets:- the AWS Easy create instructions listed in the Creating a PostgreSQL DB instance section
- the AWS Standard create instructions
- Password authentication to use database credentials only, in which case you must enter a username for the master username, as well as generate the master password.
- Password and IAM DB authentication to use IAM users and roles for the authentication of database users.
- Password and Kerberos authentication
RASA_ANALYTICS_DB_URL
to the PostgreSQL Amazon RDS DB instance URL.
Redshift
If you prefer instead to set up Amazon Redshift as your choice of data lake, you can choose to stream the data from the PostgreSQL source database within the Amazon RDS DB instance created at the PostgreSQL step to the Redshift target.Streaming from PostgreSQL to Redshift
If you meet the prerequisites for using an Amazon Redshift database as a target, you will need to implement two steps:- configure the PostgreSQL source for AWS Database Migration Service (DMS) by following these instructions
- configure the Redshift target for AWS DMS following the instructions here.
BigQuery
To stream data from PostgreSQL to BigQuery, you can use Datastream for BigQuery. Datastream for BigQuery supports several PostgreSQL deployment types, including CloudSQL. Before you begin, make sure to check the Datastream prerequisites, as well as additional Datastream networking connectivity requirements. You can closely follow this quickstart guide on replicating data from PostgreSQL CloudSQL to BigQuery with Datastream. Alternatively, you can deep dive into the following Datastream set-up guides:- Configure your source PostgreSQL database
- Optional: use customer-managed encryption keys
- Create a connection profile for PostgreSQL database
- Create a stream
Snowflake
You can sync your PostgreSQL deployment manually or via an automated partner solution. The instructions for manual sync include the following steps:- Extract data from PostgreSQL to file using
COPY INTOcommand. You should also explore the Snowflake data loading best practices before extraction. - Stage the extracted data files to either internal or external locations such as AWS S3, Google Cloud Storage or Microsoft Azure.
- Copy staged files to Snowflake tables using
COPY INTOcommand. You can decide to use bulk data loading into Snowflake or to load continuously using Snowpipe. Alternatively you can also benefit from this plugin to load data to an existing Snowflake table.
3. Ingest past conversations (optional)
When Analytics is connected to your Kafka instance, it will consume all prior events on the Kafka topic and ingest them into the database. Kafka has a retention policy for events on a topic which defaults to 7 days. If you want to process events from conversations that are older than the retention policy configured for the Rasa topic, you can manually ingest events from past conversations. Manually ingesting data from past conversations requires a connection to the tracker store. The tracker store contains past conversations and a connection to the Kafka cluster. Use therasa export command to export
the events stored in the tracker store to Kafka:
endpoints.yml
Running manual ingestion of past events multiple times will result in
duplicated events. There is currently no deduplication implemented in
Analytics. Every ingested event will be stored in the database,
even if it was processed previously.
4. Connect a BI Solution
Connecting a business intelligence platform to the data warehouse varies for each platform. We provide example instructions for Metabase and Tableau but you can use any BI platform which supports AWS Redshift or PostgreSQL.Example: Metabase
Metabase is a free and open-source business intelligence platform. It provides a simple interface to query and visualize data. Metabase can be connected to PostgreSQL or Redshift databases.Example: Tableau
Tableau is a business intelligence platform. It provides a flexible interface to build business intelligence dashboards. Tableau can be connected to PostgreSQL or Redshift databases.Kafka Dead-Letter-Queue Publishing Mechanism
Rasa Analytics supports publishing events that could not be processed to a dead-letter-queue (DLQ) topic in Kafka. This allows you to inspect the events that could not be processed and take appropriate actions. To enable the DLQ publishing mechanism, you need to set theRASA_ANALYTICS_DLQ environment variable to the name of the DLQ topic
you want to use. The DLQ topic must be created before starting the
Analytics pipeline. By default, the DLQ topic name is set to
rasa-analytics-dlq.
When an event cannot be processed, it will be published to the DLQ topic
with the original event payload and an additional header original_offset
indicating the offset of the original event in the source topic.
Reasons for events being published to the DLQ topic include event processing errors such as:
- Malformed event payloads
- Database connection issues
- Data validation errors
stack event that causes
JsonPointerException or JsonPatchConflict errors during processing.
How to reprocess events from the DLQ topic
If you want to reprocess events from the DLQ topic, we recommend you follow these steps:- Identify the minimum source topic offset for each partition among the events published to the DLQ topic.
You can do this by consuming messages from the DLQ topic and inspecting
the
original_offsetheader. - Stop the Rasa Analytics pipeline while you reset the source topic offset identified for each partition to the minimum offset identified in step 1.
- Restart the Rasa Analytics pipeline. It will start consuming events from the source topic starting from the partition offsets you set in step 2, including the events that were previously published to the DLQ topic. Events that had been successfully processed prior will be skipped, while the DLQ events that could not be processed will be re-processed and published to the DLQ topic again if they still cannot be processed.
- Once you have reprocessed the events, you can choose to mark them as processed by committing the offsets in the DLQ topic or deleting the messages from the DLQ topic.
Retry Mechanism In Event of Failures
Rasa Analytics includes a retry mechanism to handle transient failures that may occur during event processing. The retry mechanism is designed to automatically retry failed operations a configurable number of times before giving up and publishing the event to the dead-letter-queue (DLQ) topic. The number of retries can be configured using theRETRY_DB_TRANSACTION_COUNT and RETRY_CONNECTION_COUNT environment variables,
respectively. By default, both variables are set to 7.
The RETRY_DB_TRANSACTION_COUNT variable controls how many times a database transaction is retried when it fails,
while the RETRY_CONNECTION_COUNT variable controls how many times the connection to the Kafka broker is retried
when the broker is not available during operations such as message consumption, message acknowledgement, and DLQ publishing.
The retry mechanism uses an exponential backoff strategy to avoid overwhelming
the system with retries. The backoff time increases exponentially with each retry attempt.
Note that the retry mechanism will have an impact on the throughput event processing,
so it should be configured appropriately based on the expected load and performance requirements of your system.
Database Migration Best Practices
Troubleshooting Common Issues
When database migrations and index creation are handled automatically at runtime, customers with large databases and multi-replica deployments may experience the following issues:Duplicate Sender Records
Customers may observe duplicatesender_key entries in the rasa_sender table, violating the expectation of uniqueness. This can lead to runtime failures such as:
Runtime Database Migrations
Runtime logs may intermittently show messages like:Pod Restarts During Load Testing
During load tests, multiple restarts may occur in the Rasa Pro Services pod. Logs indicate failures tied to database operations, suggesting that concurrent database access during migrations can cause instability.Duplicate Session Start Events
The_rasa_raw_event table may contain multiple duplicate “session_started” events for the same sender_key. This suggests possible race conditions or duplicate initialization during pod restarts or migrations.
Index Creation Causing Crash Loops
For large databases (e.g., ~170 GB), index creation can take many minutes. During this time:- Liveness and readiness probes fail
- Kubernetes restarts the pod
- All replicas attempt migrations simultaneously, opening many database connections and hitting connection limits
- Index creation is interrupted
- Pods enter a crash loop
- Rasa Pro Services cannot start successfully
sender_id errors can occur due to concurrency issues when Rasa Pro Services restarts after a crash or interruption, causing events to be processed more than once.
Best Practices
To avoid these issues, follow these best practices:Run Migrations Outside the Main Application Lifecycle
Do not run database migrations at runtime. Instead, run migrations before application pods start by using the following approach:- Dedicated migration job: Use a Kubernetes Job to run migrations separately from the application deployment. This allows you to:
- Run migrations as a one-time operation
- Monitor migration completion independently
- Ensure migrations complete before scaling up application replicas
RUN_ANALYTICS_DB_MIGRATIONS environment variable to false.
For example, update the helm chart values.yaml under the additionalEnv section of the rasaProServices configuration:
values.yaml
Verify Migration Completion After Upgrade
After upgrading Rasa Pro Services, ensure database migrations complete successfully by verifying that the following indexes are present in the relevant tables:- A composite index on the
session_idandtimestamp ASCcolumns of therasa_eventtable - A composite index on the
sender_id,session_idandtimestamp ASCcolumns of therasa_eventtable - A composite index on the
sender_idandsequence_numbercolumns of therasa_eventtable - An index on the
sender_keycolumn of therasa_sendertable - A composite index on the
sender_idandstart_sequence_number DESCcolumns of therasa_sessiontable - A composite index on the
sender_id,session_idandstart_sequence_number DESCcolumns of therasa_turntable - A composite index on the
sender_id,session_idandstart_sequence_number DESCcolumns of therasa_dialogue_stack_frametable