A powerful command-line tool for querying Prometheus metrics with advanced autocompletion capabilities.
- π Prometheus CLI
Prometheus CLI is a modern, feature-rich tool that allows you to query Prometheus metrics from the command line with intelligent autocompletion. Built in Go for performance and reliability, it provides an intuitive interface for exploring and querying your Prometheus metrics.
- Interactive Query Interface: Query Prometheus metrics with a user-friendly command-line interface
- Formatted Table Output: Display results in clean, organized tables with automatic column alignment
- Continuous Query Mode: Stay in the application after each query for efficient metric exploration
- Cross-platform Support: Works seamlessly on Linux, macOS, and Windows
- π Metric Names: Smart autocompletion for all available Prometheus metrics
- π·οΈ Label Names: Context-aware label suggestions when typing
metric{ - π Label Values: Real-time label value suggestions with caching for performance
- β‘ PromQL Expressions: Complete support for:
- Prometheus operators (
+,-,*,/,==,!=, etc.) - Built-in functions (
rate(),sum(),avg(),count(), etc.) - Time range selectors (
[5m],[1h],[1d], etc.) - Query modifiers (
by,without,on,ignoring, etc.)
- Prometheus operators (
- π§ Context-Aware Suggestions: Intelligent suggestions based on cursor position and query context
- π Navigation Support: Tab completion with arrow key navigation for easy selection
- π Basic Authentication: Support for username/password authentication
- π‘οΈ TLS Support: Full HTTPS support with optional certificate verification
- π Insecure Mode: Skip certificate verification for development environments
- π Custom Prometheus URLs: Connect to any Prometheus server
- π Command History: Flexible command history management with options for persistent files and temporary files.
- ποΈ Configurable Options: Flexible command-line options for all features, including history and debugging.
- π Debugging: Enable verbose output for detailed error diagnosis.
-
Clone the repository:
git clone https://github.com/SckyzO/prometheus-cli.git cd prometheus-cli -
Build the binary:
make build
-
(Optional) Install the binary to your PATH:
cp bin/prom-cli /usr/local/bin/
go install github.com/SckyzO/prometheus-cli/cmd/prom-cli@latest-
Make sure Prometheus is running and accessible at
http://localhost:9090(default). -
Run Prometheus CLI:
./bin/prom-cli
-
Enter a Prometheus query when prompted. Use Tab for autocompletion of:
- Metric names
- Label names (after typing
{) - Label values (after typing
label=) - Functions and operators
-
The results will be displayed in a formatted table with clear headers and separators.
-
The application remains active after executing a query, allowing you to enter additional queries.
-
To exit the application, press Ctrl+C.
Prometheus CLI supports the following command line options:
--url Prometheus server URL (default: http://localhost:9090)
--username Username for basic authentication
--password Password for basic authentication
--insecure Skip TLS certificate verification
--enable-label-values Enable autocompletion for label values (default: true)
--history-file Path to the command history file. If not set, a temporary file is used.
--persist-history Do not delete the history file on exit. Only applicable if --history-file is set or a temporary file is used.
--debug Enable verbose error output for debugging.
--tips Display detailed feature and usage tips on startup.
--help, -h Show help
--version Show version information
Basic usage with default settings:
./bin/prom-cliConnecting to a custom Prometheus server:
./bin/prom-cli --url="http://prometheus-server:9090"Using a custom path:
./bin/prom-cli --url="https://monitoring.example.com/prometheus"With authentication:
./bin/prom-cli --url="https://prometheus-server:9090" --username="admin" --password="secret"Skipping TLS verification (for self-signed certificates):
./bin/prom-cli --url="https://prometheus-server:9090" --insecureDisabling label values autocompletion (for faster startup):
./bin/prom-cli --enable-label-values=falseHere are some screenshots demonstrating the Prometheus CLI in action:
- Go 1.21 or later
- Make (optional, for using the Makefile)
make buildmake testBuild for all platforms:
make build-allOr for specific platforms:
make build-linux
make build-windows
make build-macosMajor Features:
- π Configurable History: Added
--history-fileand--persist-historyflags for flexible command history management. - π Improved Debugging: Enhanced
--debugflag with more verbose output for initialization and error diagnosis. - π‘ Optional Tips: Introduced
--tipsflag to control the display of detailed feature and usage tips on startup. - π Optimized Table Display: Improved table rendering for queries with many labels, preventing excessive width issues.
Technical Enhancements:
- Refined error handling and logging for better debugging experience.
- Improved command-line option parsing and validation.
- Implemented intelligent column limiting and header truncation for better readability.
- Fixed compilation issues with help text formatting.
Major Features:
- π Complete rewrite in Go for better performance and reliability
- ποΈ Clean architecture with modular design (
cmd/,internal/structure) - π§ Advanced autocompletion system with context-aware suggestions
- π Intelligent table display with automatic column organization
- π Enhanced security with full TLS and authentication support
- β‘ Performance optimizations with caching and efficient data structures
- π§ͺ Comprehensive testing with unit and integration tests
- π¦ Cross-platform binaries with automated GitHub Actions builds
- ποΈ Flexible configuration with extensive command-line options
Autocompletion Improvements:
- Smart metric name completion with fuzzy matching
- Context-aware label and label value suggestions
- Complete PromQL syntax support (operators, functions, modifiers)
- Efficient caching system for label values
- Tab navigation with arrow key support
- Priority-based suggestion ordering
Technical Enhancements:
- Refactored codebase with proper Go package structure
- Automated testing and continuous integration
- Memory-efficient data structures and algorithms
- Robust error handling and user feedback
- Basic Prometheus querying functionality
- Simple table output
- Basic metric name autocompletion
prometheus-cli/
βββ cmd/prom-cli/ # Main application entry point
βββ internal/
β βββ completion/ # Advanced autocompletion system
β βββ prometheus/ # Prometheus API client
β βββ display/ # Table display functionality
βββ test/ # Integration tests
βββ python/ # Original Python implementation (v1.0)
βββ bin/ # Compiled binaries
βββ Makefile # Build automation
This project is licensed under the MIT License - see the LICENSE file for details.




