Compare commits
4 Commits
53915cec63
...
d8c08778f9
| Author | SHA1 | Date | |
|---|---|---|---|
|
d8c08778f9
|
|||
|
9d9782f77c
|
|||
|
2cb42aa8e9
|
|||
|
efaa322a66
|
46
CLAUDE.md
Normal file
46
CLAUDE.md
Normal 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.
|
||||
27
README.md
27
README.md
@@ -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
6
flake.lock
generated
@@ -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
2
go.mod
@@ -1,4 +1,4 @@
|
||||
module git.t-juice.club/torjus/alerttonotify
|
||||
module code.t-juice.club/torjus/alerttonotify
|
||||
|
||||
go 1.23.3
|
||||
|
||||
|
||||
Reference in New Issue
Block a user