Skip to content

MichielVanderhoydonck/sloak

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SLOAK: Service-Level-Objective Army Knife

sloak is a command-line tool designed to simplify Service Level Objective (SLO) engineering. It provides utilities for calculating error budgets, burn rates, feasibility, and more, helping SREs and developers build more reliable systems.

Inspired by the Google SRE Workbook.


Word of Warning

AI was used in the form of the Antigravity IDE with the Gemini LLM to speed up coding. The LLM was guided into using desired frameworks in an exploratory manner, had to follow general golang standards as well as clean architecture. If you want to re-use this or build from it I advice you to review thouroughly.

🚀 Getting Started

The easiest way to start is by calculating an error budget for a standard SLO.

# Calculate 99.9% SLO over 30 days
sloak calculate errorbudget --slo 99.9 --window 30d

# Get machine-readable JSON for Prometheus/Automation
sloak calculate errorbudget --slo 99.9 --window 30d --output json

Configuration

SLOAK supports file-based configuration and environment variables to set team-wide global defaults (like your SLO, time window, MTTR, etc).

To generate a starting configuration template, simply run:

sloak init > .sloak.yaml

Once .sloak.yaml is placed in your home directory or current working directory (or using SLOAK_ prefixed environment variables like SLOAK_SLO=95.0), you can omit those flags!

# Automatically uses 'slo' and 'window' from your config
sloak calculate errorbudget

Common Commands

  • Calculate Burn Rate: See how fast you're consuming your budget.
    sloak calculate burnrate --slo 99.9 --window 30d --elapsed 7d --consumed 30m
  • Feasibility Analysis: Check if your MTTR is realistic for your SLO.
    sloak calculate feasibility --slo 99.9 --mttr 1h
  • Max Disruption: Calculate how many deployments you can afford.
    sloak calculate max-disruption --slo 99.9 --cost 2m
  • Template Rendering: Render observability configs from BYOT templates (Prometheus Operator, Datadog, etc).
    sloak render --template ./templates/prometheus_operator_mwmbr.cue --slo 99.9 --set metric_name=checkout_flow --set namespace=billing

🛠 Installation & Building

Building from Source

# Clone the repository
git clone https://github.com/MichielVanderhoydonck/sloak.git
cd sloak

# Build the binary
go build -o sloak cmd/sloak/main.go

# (Optional) Install to your GOBIN
go install ./cmd/sloak

📖 Command Reference

Command Description
init Prints a default .sloak.yaml configuration template.
calculate errorbudget Allowed failure time for a given SLO and window.
calculate burnrate Current budget consumption speed and exhaustion forecast.
calculate feasibility Required MTBF given a target SLO and MTTR.
calculate dependency Composite availability for serial/parallel systems.
calculate max-disruption Frequency limits based on deployment disruption cost.
convert Translate between availability % and downtime duration.
generate alert-table Generate a standard multi-window, multi-burn-rate alert table.
render Render observability rules using a BYOT CUE template.

Global Flags

  • --config string: Override the path to the configuration file (default is $HOME/.sloak.yaml or ./.sloak.yaml).
  • -o, --output string: Set output format. Use json for machine-readable data (useful for Prometheus alerting config).

🏗 Architecture & Linting

sloak follows Clean Architecture principles:

  • Domain (internal/domain): Core business rules and interfaces (Service). Depends on nothing.
  • Service (internal/service): Concrete implementation of domain logic. Depends on Domain.
  • CLI Commands (cmd/convert, etc.): Delivery mechanism. Depends only on Domain. They are strictly prohibited from importing package internal/service.
  • Composition Root (cmd/root.go, cmd/sloak/main.go): Bootstrap layer. Allowed to import both cmd and internal/service to wire concrete services to commands via dependency injection.

Architecture Linting

We use go-arch-lint to enforce these architectural boundaries.

docker run --rm -v ${PWD}:/app fe3dback/go-arch-lint:latest check --project-path /app

🧪 Testing

Unit & Service Tests

go test ./...

End-to-End (E2E) Tests

Verified against the actual compiled binary.

go test -v -tags=e2e ./test/e2e

About

SLOAK (Service Level Objective Army Knife)

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors