How rejohnst/promclient works
Project type and purpose
• This is an open-source, command-line interface (CLI) tool (“promclient”) written in Go.
• Its sole purpose is to query and display various aspects of a Prometheus server via its HTTP API: alerts, metrics metadata, active rule status, target health, runtime configuration, and arbitrary PromQL queries.
File structure
• Top‐level files:
• main.go → CLI entry point (flag parsing, command dispatch)
• go.mod / go.sum / Makefile → dependency and build config
• README.md / LICENSE / .gitignore → documentation and housekeeping
• internal/ directory: each subdirectory implements one command’s logic:
• internal/alerts
• internal/metrics
• internal/query
• internal/rules
• internal/runtime
• internal/targets
• Each module contains one Go source file (e.g., alerts.go) exposing a function that:
• Builds the appropriate HTTP request
• Parses the JSON response
• Applies filters (e.g. severity, active/down, CSV output)
• Formats and prints to stdout
Key insights from README
• Lists six top‐level commands (alerts, metrics, query, rules, runtime, targets) each mapping 1:1 to internal subpackages.
• Common flags (–promurl, –promip, –timeout, –insecure, –verbose) are parsed centrally in main.go.
• Behavior: synchronous HTTP GET calls to Prometheus REST endpoints, then CLI output.