Nyx is a GoLang demo application designed for validating Kubernetes controllers, Prometheus metrics, and modern cloud-native best practices. It provides a simple HTTP API and exposes Prometheus metrics, making it ideal for testing, learning, and integration with Kubernetes monitoring stacks.
- HTTP API: Simple endpoints for demo and health checks.
- Prometheus Metrics: Exposes HTTP request counters and histograms for monitoring.
- Kubernetes Native: Includes manifests for deployment, service, and ServiceMonitor.
- Configurable: Supports configuration via YAML file, environment variables, and command-line flags.
- Graceful Shutdown: Handles SIGINT/SIGTERM for clean exits.
- Go 1.24+
- Docker (optional, for container builds)
- Kubernetes cluster (for deployment)
- Prometheus Operator (for ServiceMonitor support)
-
Clone the repository
git clone https://github.com/MatteoMori/nyx.git cd nyx -
Build and run
go build -o nyx ./nyx start
-
Access the API
- HTTP server: http://localhost:8080/hello
- Metrics: http://localhost:9090/metrics
Nyx supports configuration via:
- YAML file (
nyx.yaml) - Environment variables
- Command-line flags
Example nyx.yaml:
prometheusPort: "9090"
verbosity: 1Environment variable override:
export PROMETHEUSPORT=12345
./nyx start-
Apply the manifests
kubectl apply -f manifests/
-
Expose metrics to Prometheus
kubectl apply -f manifests/servicemonitor.yaml
-
Access the app
- HTTP: via the
nyxservice on port 80 - Metrics: via the
nyx-metricsservice on port 9090
- HTTP: via the
Nyx exposes the following Prometheus metrics:
http_requests_total{path,method,status}: Total number of HTTP requests.http_request_duration_seconds{path,method}: Histogram of request durations.
Metrics are available at /metrics on the configured Prometheus port (default: 9090).
.
├── cmd/ # CLI entrypoints (Cobra)
├── manifests/ # Kubernetes manifests
├── pkg/
│ ├── nyx/ # Application logic and metrics
│ └── shared/ # Shared config types
├── main.go # Main entrypoint
├── nyx.yaml # Example config
├── Dockerfile # Multi-stage build for container images
└── README.md # This file
