NATS¶
Publish alert payloads to a NATS subject. Use this to fan alerts out to internal consumers — log pipelines, custom routing, incident automation — without going through HTTP.
Prerequisites¶
Your NATS server must be reachable from the Wanepia notify service. For self-hosted deployments, set NATS_URL on the notify container.
Adding a NATS channel¶
Config fields¶
| Key | Required | Description |
|---|---|---|
subject |
Yes | NATS subject to publish to |
Payload format¶
The same JSON object as the webhook payload:
{
"entity_id": "...",
"entity_name": "payments-api",
"check_id": "...",
"tenant_id": "...",
"from_state": "up",
"to_state": "down",
"transition_id": "...",
"timestamp": "2024-01-20T03:17:42Z"
}
Example: consuming alerts in Go¶
nc, _ := nats.Connect("nats://localhost:4222")
nc.Subscribe("alerts.>", func(msg *nats.Msg) {
var event map[string]interface{}
json.Unmarshal(msg.Data, &event)
fmt.Printf("Alert: %s → %s for %s\n",
event["from_state"], event["to_state"], event["entity_name"])
})
Subject naming conventions¶
Use dot-separated subjects for easy filtering:
alerts.state-changes # catch-all
alerts.state-changes.down # only down transitions
alerts.state-changes.up # only recovery
wanepia.{tenant_id}.alerts # tenant-scoped
NATS wildcards work for consumers:
- alerts.* — one token wildcard
- alerts.> — multi-token wildcard