Compare commits

..

4 Commits

Author SHA1 Message Date
d8c08778f9 Improve README with configuration, build, and usage info
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 19:07:46 +01:00
9d9782f77c Migrate module path from git.t-juice.club to code.t-juice.club
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 19:06:55 +01:00
2cb42aa8e9 Update nixpkgs flake input to 2026-03-06
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 19:04:41 +01:00
efaa322a66 Add CLAUDE.md with project guidance for Claude Code
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 19:03:39 +01:00
5 changed files with 74 additions and 9 deletions

46
CLAUDE.md Normal file
View File

@@ -0,0 +1,46 @@
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
alerttonotify receives Alertmanager HTTP webhooks and forwards them as notifications via NATS to a dbus notify service. Written in Go (1.23.3).
## Build & Development
```bash
# Build
go build -v ./...
# Lint (available in nix devshell)
golangci-lint run
# Enter dev environment (requires nix with flakes)
nix develop
# Build with nix
nix build
```
No tests exist yet. The project uses direnv (`.envrc`) to auto-load the nix devshell.
## Architecture
**main.go** — Entry point. Reads config from environment variables, sets up NATS connection, creates the HTTP server, handles graceful shutdown on SIGINT.
**server/server.go** — HTTP server with two routes:
- `GET /` — health check
- `POST /alert` — receives Alertmanager webhook payloads (`AlertMessage`/`Alert` structs), builds a summary, and publishes via `NotificationService`
**server/notify.go**`NotificationService` wraps a NATS connection. Serializes `BusNotification` (summary, body, timeout) to JSON and publishes to subject `home2rjusnet.notifications`. Uses NKey authentication.
## Configuration
All config is via environment variables:
- `NATS_URL` (required) — NATS server URL
- `NATS_NKEY` or `NATS_NKEY_FILE` (required) — NKey seed for NATS auth
- `ALERTTONOTIFY_ADDR` (optional, default `:5001`) — HTTP listen address
## Nix
The flake builds with `buildGoModule`. The `vendorHash` in `flake.nix` must be updated when Go dependencies change.

View File

@@ -1,8 +1,27 @@
# Alert-to-notify
# alerttonotify
Receives HTTP requests from alertmanager. Sends to DBUS notify.
Receives Alertmanager webhook notifications and forwards them via NATS to a dbus notification service.
# Usage
## Configuration
TODO
All configuration is via environment variables:
| Variable | Required | Description |
|---|---|---|
| `NATS_URL` | Yes | NATS server URL |
| `NATS_NKEY` or `NATS_NKEY_FILE` | Yes | NKey seed for NATS authentication |
| `ALERTTONOTIFY_ADDR` | No | HTTP listen address (default `:5001`) |
## Building
```bash
# With Go
go build -v ./...
# With Nix
nix build
```
## Usage
Point an Alertmanager webhook receiver at `http://<host>:5001/alert`.

6
flake.lock generated
View File

@@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1732837521,
"narHash": "sha256-jNRNr49UiuIwaarqijgdTR2qLPifxsVhlJrKzQ8XUIE=",
"lastModified": 1772773019,
"narHash": "sha256-E1bxHxNKfDoQUuvriG71+f+s/NT0qWkImXsYZNFFfCs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "970e93b9f82e2a0f3675757eb0bfc73297cc6370",
"rev": "aca4d95fce4914b3892661bcb80b8087293536c6",
"type": "github"
},
"original": {

2
go.mod
View File

@@ -1,4 +1,4 @@
module git.t-juice.club/torjus/alerttonotify
module code.t-juice.club/torjus/alerttonotify
go 1.23.3

View File

@@ -8,7 +8,7 @@ import (
"os/signal"
"strings"
"git.t-juice.club/torjus/alerttonotify/server"
"code.t-juice.club/torjus/alerttonotify/server"
)
const Version = "v0.1.1"