Analytics & Observability
Learn how to use analytics and and logging with R2R
Introduction
This guide demonstrates how to leverage R2R’s powerful analytics and logging features. These capabilities allow you to monitor system performance, track usage patterns, and gain valuable insights into your RAG application’s behavior.
The features described in this cookbook are typically restricted to superusers. Ensure you have the necessary permissions before attempting to access these features.
For more information on user roles and permissions, including how to set up and manage superuser accounts, please refer to our User Auth Cookbook.
Setup
Before diving into the authentication features, ensure you have R2R installed and configured as described in the installation guide. For this guide, we’ll use the default configuration. Further, r2r serve
must be called to serve R2R in either your local environment or local Docker engine.
Basic Usage
Logging
R2R automatically logs various events and metrics during its operation.
To fetch our logs using the client-server architecture, use the following:
CLI
Python
JavaScript
Curl
Expected Output:
These logs provide detailed information about each operation, including search results, queries, latencies, and LLM responses.
To fetch the logs directly from an instantiated R2R object:
Analytics
R2R offers an analytics feature that allows you to aggregate and analyze log data:
The relevant command
CLI
Python
JavaScript
Curl
Expected Output:
To fetch the analytics directly from an instantiated R2R object:
The boilerplate analytics implementation allows you to:
- Filter logs based on specific criteria
- Perform statistical analysis on various metrics (e.g., search latencies)
- Track performance trends over time
- Identify potential bottlenecks or areas for optimization
Experimental Features
Advanced analytics features are still in an experimental state - please reach out to the R2R team if you are interested in configuring / using these additional features.
Custom Analytics
R2R’s analytics system is flexible and allows for custom analysis. You can specify different filters and analysis types to focus on specific aspects of your application’s performance.
Preloading Data for Analysis
To get meaningful analytics, you need a substantial amount of data. Here’s a script to preload your database with random searches:
After running this script, you’ll have a rich dataset to analyze using the analytics features described above.
User-Level Analytics
To get analytics for a specific user:
This will give you insights into the behavior and performance of specific users in your system.
Summary
R2R’s logging and analytics features provide powerful tools for understanding and optimizing your RAG application. By leveraging these capabilities, you can:
- Monitor system performance in real-time
- Analyze trends in search and RAG operations
- Identify potential bottlenecks or areas for improvement
- Track user behavior and usage patterns
- Make data-driven decisions to enhance your application’s performance and user experience
For detailed setup and basic functionality, refer back to the R2R Quickstart. For more advanced usage and customization options, join the R2R Discord community.