slogo

Go utilities for working with OpenSLO (Service Level Objectives) specifications.
Overview
slogo is a Go library that provides convenient utilities for reading, writing, and validating OpenSLO specification files. It builds on top of the OpenSLO Go SDK to provide a simpler interface for working with SLO definitions in JSON and YAML formats.
Features
- Read OpenSLO objects from files or readers (auto-detects JSON/YAML format)
- Write OpenSLO objects to files in JSON or YAML format
- Validate SLO definitions against the OpenSLO specification
- Type-safe Go representations of SLO objects
- Predefined severity and attribute constants
Installation
go get github.com/grokify/slogo
Usage
Reading SLO Files
import "github.com/grokify/slogo"
// Read from file (auto-detects JSON or YAML)
objs, err := slogo.ReadFile("slo-definition.yaml")
if err != nil {
log.Fatal(err)
}
// Read from io.Reader
objs, err := slogo.Read(reader)
if err != nil {
log.Fatal(err)
}
Validating SLO Objects
// Validate all objects
if err := objs.Validate(); err != nil {
log.Fatal(err)
}
Writing SLO Files
// Write as YAML
err := objs.WriteFileYAML("output.yaml")
if err != nil {
log.Fatal(err)
}
// Write as JSON
err := objs.WriteFileJSON("output.json")
if err != nil {
log.Fatal(err)
}
Using Predefined Constants
import "github.com/grokify/slogo"
// Severity levels
severity := slogo.SeverityCritical // "critical"
severity := slogo.SeverityHigh // "high"
severity := slogo.SeverityMedium // "medium"
severity := slogo.SeverityLow // "low"
severity := slogo.SeverityInfo // "info"
// Attributes
attr := slogo.AttrQuery // "query"
Examples
The examples directory contains real-world examples of SLO definitions with detailed explanations:
Compares different budgeting methods (Occurrences, Timeslices, and RatioTimeslices) with practical examples:
- Availability SLO (
timeslices-slo.go) - Reflects an SLA for internet provider availability (99% uptime)
- Occurrences SLO (
occurences-slo.go) - Measures search latency treating all searches equally
- Ratio Timeslices SLO (
ratio-timeslices.go) - Tracks main page availability based on response codes
Demonstrates how to maintain high reliability regardless of traffic volume, ensuring that services with low usage receive the same attention as high-traffic services.
Each example includes:
- Complete, working Go code
- Detailed descriptions of what is being measured
- Explanations of why specific budgeting methods are chosen
- Automated tests to validate the SLO definitions
Dependencies
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Resources