Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## main / (unreleased)

* [CHANGE] eventrecorder: The output data format now uses the new `events/v2` schema. This is a breaking change: alert labels, alert annotations, group labels, silence annotations, and muted-alert labels are JSON maps, and protobuf consumers must use the new schema.
Comment thread
siavashs marked this conversation as resolved.

## 0.34.0 / 2026-08-16

* [CHANGE] notify: The `reason` label on `alertmanager_notifications_failed_total` now distinguishes `authError` (HTTP 401/403) and `rateLimited` (HTTP 429) from the generic `clientError`. Dashboards/alerts matching `reason="clientError"` for these codes must be updated. #5332
Expand Down
20 changes: 4 additions & 16 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import (
"github.com/prometheus/alertmanager/config"
"github.com/prometheus/alertmanager/dispatch"
"github.com/prometheus/alertmanager/eventrecorder"
"github.com/prometheus/alertmanager/eventrecorder/eventrecorderpb"
"github.com/prometheus/alertmanager/httpserver"
"github.com/prometheus/alertmanager/marker"
"github.com/prometheus/alertmanager/nflog"
Expand Down Expand Up @@ -265,23 +264,12 @@ func (a *App) setup() error {
a.onStop("event recorder", eventRec.Close)

recordCtx := eventrecorder.WithEventRecording(context.Background())
eventRec.RecordEvent(recordCtx, func() *eventrecorderpb.EventData {
return &eventrecorderpb.EventData{
EventType: &eventrecorderpb.EventData_AlertmanagerStartupEvent{
AlertmanagerStartupEvent: &eventrecorderpb.AlertmanagerStartupEvent{
Version: version.Version,
BuildContext: version.BuildContext(),
},
},
}
eventRec.RecordEvent(recordCtx, func() eventrecorder.EventData {
return eventrecorder.NewAlertmanagerStartupEvent(version.Version, version.BuildContext())
})
a.onStop("shutdown event", func() error {
eventRec.RecordEvent(recordCtx, func() *eventrecorderpb.EventData {
return &eventrecorderpb.EventData{
EventType: &eventrecorderpb.EventData_AlertmanagerShutdownEvent{
AlertmanagerShutdownEvent: &eventrecorderpb.AlertmanagerShutdownEvent{},
},
}
eventRec.RecordEvent(recordCtx, func() eventrecorder.EventData {
return eventrecorder.NewAlertmanagerShutdownEvent()
})
return nil
})
Expand Down
4 changes: 2 additions & 2 deletions buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ version: v2
modules:
- path: cluster/clusterpb
name: prometheus/alertmanager/cluster
- path: eventrecorder/eventrecorderpb
name: prometheus/alertmanager/eventrecorder
- path: nflog/nflogpb
name: prometheus/alertmanager/nflog
- path: proto/api
name: prometheus/alertmanager/api
- path: proto/eventrecorder
name: prometheus/alertmanager/eventrecorder
- path: silence/silencepb
name: prometheus/alertmanager/silence
19 changes: 7 additions & 12 deletions dispatch/dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (

"github.com/prometheus/alertmanager/alert"
"github.com/prometheus/alertmanager/eventrecorder"
"github.com/prometheus/alertmanager/eventrecorder/eventrecorderpb"
"github.com/prometheus/alertmanager/marker"
"github.com/prometheus/alertmanager/notify"
"github.com/prometheus/alertmanager/pkg/labels"
Expand Down Expand Up @@ -890,7 +889,7 @@ func (ag *aggrGroup) insert(ctx context.Context, alert *alert.Alert) bool {
span.RecordError(err)
ag.logger.Error(message, "err", err)
} else {
ag.recorder.RecordEvent(ctx, func() *eventrecorderpb.EventData {
ag.recorder.RecordEvent(ctx, func() eventrecorder.EventData {
return notify.NewAlertGroupedEvent(ag.alertGroupInfo(), alert)
})
// The alert set changed; the alert is already visible via ag.alerts.
Expand Down Expand Up @@ -965,21 +964,17 @@ func (ag *aggrGroup) recordResolvedEvents(resolved types.AlertSlice) {
if len(resolved) == 0 {
return
}
groupInfo := ag.alertGroupInfo()
for _, a := range resolved {
ag.recorder.RecordEvent(ag.ctx, func() *eventrecorderpb.EventData {
return notify.NewAlertResolvedEvent(groupInfo, a)
ag.recorder.RecordEvent(ag.ctx, func() eventrecorder.EventData {
return notify.NewAlertResolvedEvent(ag.alertGroupInfo(), a)
})
}
}

func (ag *aggrGroup) alertGroupInfo() *eventrecorderpb.AlertGroupInfo {
return &eventrecorderpb.AlertGroupInfo{
GroupKey: ag.GroupKey(),
GroupLabels: eventrecorder.LabelSetAsProto(ag.labels),
GroupId: notify.Key(ag.GroupKey()).Hash(),
ReceiverName: ag.opts.Receiver,
}
func (ag *aggrGroup) alertGroupInfo() eventrecorder.AlertGroup {
return eventrecorder.NewAlertGroup(
ag.GroupKey(), ag.labels, notify.Key(ag.GroupKey()).Hash(), ag.opts.Receiver, nil, "",
)
}

type nilLimits struct{}
Expand Down
13 changes: 11 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2175,6 +2175,12 @@ stdout_outputs:
[ - <stdout_output> ... ]
```

Every output uses the schema in `proto/eventrecorder/events/v2/events.proto`.
Alert labels, alert annotations, group labels, silence annotations, and
muted-alert labels are encoded as maps. Protobuf consumers must use the Go
package `github.com/prometheus/alertmanager/eventrecorder/events/v2` or bindings
generated from that schema.

#### `<file_output>`

Writes each event as a single JSON line to a file. The file is reopened
Expand Down Expand Up @@ -2234,7 +2240,10 @@ url: <secret>

For example, [Cloudflare Pipelines streams](https://developers.cloudflare.com/pipelines/streams/writing-to-streams/)
accept JSON arrays through their HTTP ingestion endpoints and can be configured
as a batched webhook output:
as a batched webhook output. Because the event timestamp field is named
`@timestamp`, quote it when referencing it from the pipeline SQL. A complete
fan-out example is available under
[`doc/examples/cloudflare-pipelines`](https://github.com/prometheus/alertmanager/blob/main/doc/examples/cloudflare-pipelines/README.md).

```yaml
event_recorder:
Expand Down Expand Up @@ -2277,7 +2286,7 @@ topic: <string>
# On-the-wire encoding for each record value: "json" (protojson) or
# "protobuf" (binary proto). JSON is the default for symmetry with the
# file and webhook outputs; consumers that already use the
# eventrecorder.proto schema may prefer protobuf for compactness.
# selected event recorder protobuf schema may prefer protobuf for compactness.
[ format: <"json" | "protobuf"> | default = "json" ]

# Producer acknowledgement level. "leader" matches the franz-go default
Expand Down
Loading
Loading