Introduction
Snuba provides a powerful command-line interface (CLI) for managing all aspects of the application, from running services to managing migrations and consuming Kafka streams. The CLI is built using Click and follows a plugin-based architecture where each command is a separate module.CLI Architecture
The Snuba CLI uses a dynamic command loading system defined insnuba/cli/__init__.py:29. Commands are automatically discovered from Python files in the cli directory, with underscores converted to dashes (e.g., rust_consumer.py becomes rust-consumer).
Available Commands
Snuba provides the following command categories:Core Service Commands
api
Run the main Snuba HTTP API server
admin
Run the administrative web interface
devserver
Start all services for local development
Data Processing Commands
consumer
Python-based Kafka consumer for event processing
rust-consumer
High-performance Rust-based consumer
replacer
Process replacement messages for data updates
subscriptions-executor
Execute scheduled subscription queries
Database Management
migrations
Manage ClickHouse schema migrations
bootstrap
Initialize Kafka topics and run migrations
Command Features
Auto-Initialization
All commands automatically initialize Snuba’s core components before execution. This includes:- Setting up Sentry error tracking
- Configuring structured logging
- Initializing metrics collection
- Loading storage and dataset factories
Logging Configuration
Most commands support the--log-level option to control output verbosity:
critical- Only critical errorserror- Error messageswarning- Warnings and errorsinfo- Informational messages (default)debug- Detailed debugging informationtrace- Verbose trace-level logging (Rust consumers)
API Server
The main HTTP API server that handles query requests:Address to listen on in format
host:portEnable debug mode with auto-reload (development only)
Logging level (critical, error, warning, info, debug)
Number of worker processes (min: 1)
Number of threads per process (min: 1)
Socket connection backlog (min: 128)
Examples
In debug mode, only a single process and thread can be used. The server will automatically reload when code changes are detected.
Bootstrap
Initialize Snuba’s infrastructure by creating Kafka topics and running migrations:Kafka bootstrap servers (can be specified multiple times)
Whether to create Kafka topics
Whether to run database migrations
Required flag to confirm bootstrap operation
Logging level to use
Examples
Common Patterns
Storage Selection
Many commands require specifying a storage target:entities command.
Kafka Configuration
Commands that interact with Kafka support multiple bootstrap servers:Health Checks
Consumer commands support health check files for orchestration:Version Information
Display Snuba version:Getting Help
Every command supports the--help flag:
Next Steps
Consumer Commands
Learn about Kafka consumers and event processing
Migrations
Manage database schema changes
Development Server
Set up local development environment
Admin Interface
Administrative tools and interfaces