An open API service indexing awesome lists of open source software.

https://github.com/lex00/wetwire-observability-go

Prometheus, Alertmanager, and Grafana configuration synthesis using Go struct literals
https://github.com/lex00/wetwire-observability-go

Last synced: 5 months ago
JSON representation

Prometheus, Alertmanager, and Grafana configuration synthesis using Go struct literals

Awesome Lists containing this project

README

          

# wetwire-observability (Go)

[![CI](https://github.com/lex00/wetwire-observability-go/actions/workflows/ci.yml/badge.svg)](https://github.com/lex00/wetwire-observability-go/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/lex00/wetwire-observability-go/branch/main/graph/badge.svg)](https://codecov.io/gh/lex00/wetwire-observability-go)
[![Go Reference](https://pkg.go.dev/badge/github.com/lex00/wetwire-observability-go.svg)](https://pkg.go.dev/github.com/lex00/wetwire-observability-go)
[![Go Report Card](https://goreportcard.com/badge/github.com/lex00/wetwire-observability-go)](https://goreportcard.com/report/github.com/lex00/wetwire-observability-go)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Release](https://img.shields.io/github/v/release/lex00/wetwire-observability-go.svg)](https://github.com/lex00/wetwire-observability-go/releases)

Prometheus, Alertmanager, and Grafana configuration synthesis using Go struct literals.

## Installation

```bash
go install github.com/lex00/wetwire-observability-go/cmd/wetwire-obs@latest
```

## Quick Example

```go
package monitoring

import (
"time"
"github.com/lex00/wetwire-observability-go/prometheus"
"github.com/lex00/wetwire-observability-go/alertmanager"
"github.com/lex00/wetwire-observability-go/rules"
"github.com/lex00/wetwire-observability-go/grafana"
"github.com/lex00/wetwire-observability-go/promql"
)

// Shared PromQL expression used in both alert and dashboard
var ErrorRateExpr = promql.GT(
promql.Div(
promql.Sum(promql.Rate(promql.Vector("http_requests_total",
promql.Match("status", "5..")), "$__rate_interval"), "service"),
promql.Sum(promql.Rate(promql.Vector("http_requests_total"),
"$__rate_interval"), "service"),
),
promql.Scalar(0.05),
)

// Alert using shared expression
var HighErrorRate = rules.AlertingRule{
Alert: "HighErrorRate",
Expr: ErrorRateExpr,
For: 5 * time.Minute,
Severity: rules.Critical,
}

// Dashboard panel using same expression
var ErrorRatePanel = grafana.StatPanel{
Title: "Error Rate",
Targets: []any{grafana.PrometheusTarget{RefID: "A", Expr: ErrorRateExpr}},
}
```

```bash
# Generate standalone configs
wetwire-obs build . --mode=standalone
# Output: prometheus.yml, alertmanager.yml, rules/*.yml, dashboards/*.json

# Generate Prometheus Operator CRDs
wetwire-obs build . --mode=operator
# Output: manifests/*.yaml (ServiceMonitor, PrometheusRule, etc.)
```

## Features

- **Unified observability stack** - Prometheus, Alertmanager, and Grafana in one package
- **Shared PromQL types** - Same expression builders for alerts and dashboards
- **Dual output mode** - Standalone configs or Prometheus Operator CRDs
- **Row-based layout** - Auto-positioned Grafana panels
- **Type-safe references** - Direct variable references, IDE autocomplete
- **Lint enforcement** - WOB rules ensure consistent patterns

## AI-Assisted Design

Create observability configuration interactively with AI:

```bash
# Interactive design session
wetwire-obs design "Add monitoring for my API service"

# Automated testing with personas
wetwire-obs test --persona beginner "Create error rate dashboard"
```

Requires `ANTHROPIC_API_KEY`. See [CLI Reference](docs/CLI.md#design) for details.

## Documentation

- [Quick Start](docs/QUICK_START.md) - Full tutorial
- [CLI Reference](docs/CLI.md) - All commands
- [Lint Rules](docs/LINT_RULES.md) - WOB rule reference
- [FAQ](docs/FAQ.md) - Common questions

## Development

```bash
git clone https://github.com/lex00/wetwire-observability-go.git
cd wetwire-observability-go
go mod download
go test ./...
```

## License

MIT - See [LICENSE](LICENSE) for details.