Skip to content

stackrox/sensor-metrics-analyzer

Repository files navigation

StackRox Sensor Metrics Analyzer

A standalone Go binary that analyzes StackRox Sensor Prometheus metrics using declarative TOML rule files.

Made with VHS

๐ŸŽฌ Demos

Interactive TUI Mode

TUI Demo

CLI Mode (Console & Markdown)

CLI Demo

โœจ Features

  • ๐ŸŽฎ Interactive TUI: Beautiful terminal UI with keyboard navigation (powered by Bubble Tea)
  • ๐Ÿ“Š Load-Aware Analysis: Automatically detects cluster load level (low/medium/high) and adjusts thresholds accordingly
  • ๐Ÿ”— Correlation Rules: Rules can reference other metrics for intelligent status evaluation
  • ๐Ÿท๏ธ ACS Versioning: Rules specify supported ACS versions and are filtered automatically
  • ๐Ÿ“ Template-Based Reports: Markdown reports generated from templates
  • ๐Ÿ–ฅ๏ธ Console Output: Default colorful console output with tables

Installation

make build

Usage

โš ๏ธ Note: Flags must come BEFORE the metrics file!

Interactive TUI Mode (Recommended)

# Launch interactive terminal UI
./bin/metrics-analyzer analyze --format tui --rules ./automated-rules metrics.txt

TUI Features:

  • Navigate results with โ†‘/โ†“ or j/k keys
  • Press Enter to view detailed information
  • Filter by status with 1-4 keys (All/Red/Yellow/Green)
  • Search with / key
  • Press ? for help

Console & Markdown Output

# Analyze metrics (console output - default)
./bin/metrics-analyzer analyze metrics.txt

# Analyze with custom rules directory
./bin/metrics-analyzer analyze --rules ./automated-rules metrics.txt

# Generate markdown report
./bin/metrics-analyzer analyze --format markdown --output report.md metrics.txt

# Override load level
./bin/metrics-analyzer analyze --load-level high metrics.txt

# Specify ACS version
./bin/metrics-analyzer analyze --acs-version 4.8 metrics.txt

Utility Commands

# Validate rules (defaults to current directory)
./bin/metrics-analyzer validate

# Validate rules in specific directory
./bin/metrics-analyzer validate ./automated-rules

# List all rules
./bin/metrics-analyzer list-rules

TUI Keyboard Shortcuts

Key Action
โ†‘/k, โ†“/j Navigate up/down
Enter/โ†’ View details
โ†/Esc Go back
g/Home Go to top
G/End Go to bottom
PgUp/PgDn Page up/down
/ Search/filter
1-4 Filter by status (All/Red/Yellow/Green)
? Toggle help
q Quit

Project Structure

sensor-metrics-analyzer-go/
โ”œโ”€โ”€ cmd/metrics-analyzer/    # CLI entry point
โ”œโ”€โ”€ internal/
โ”‚   โ”œโ”€โ”€ parser/              # Prometheus metrics parser
โ”‚   โ”œโ”€โ”€ rules/               # TOML rule loader and validator
โ”‚   โ”œโ”€โ”€ loadlevel/           # Load level detection engine
โ”‚   โ”œโ”€โ”€ evaluator/           # Rule evaluation logic
โ”‚   โ”œโ”€โ”€ reporter/            # Report generation (markdown/console)
โ”‚   โ””โ”€โ”€ tui/                 # Interactive terminal UI (Bubble Tea)
โ”œโ”€โ”€ automated-rules/         # TOML rule definitions
โ””โ”€โ”€ templates/               # Report templates

Testing

# Unit tests
make test

# Integration test (compare with Python output)
python3 analyze_metrics_full.py metrics.txt > /tmp/python-output.txt
./bin/metrics-analyzer analyze --format markdown --output /tmp/go-report.md metrics.txt
go run testdata/compare_outputs.go /tmp/python-output.txt /tmp/go-report.md

Recording Demos

This project uses VHS for recording terminal demos. See the demo/ folder for scripts and instructions.

# Install VHS
brew install vhs

# Record demos
cd demo
vhs demo.tape       # Full TUI demo
vhs demo-cli.tape   # CLI mode demo

# Publish to charm servers
vhs publish demo.gif

Dependencies

Built with:

License

Apache 2.0 - See LICENSE for details.

About

Analyze metrics from Stackrox Sensor and discover potential problems

Resources

License

Stars

Watchers

Forks

Releases

No releases published