Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix(alertmanager): remove ambiguous reference to org_id (#9955)

Vikrant Gupta5449374ad844
diff --git a/pkg/alertmanager/alertmanagerserver/server.go b/pkg/alertmanager/alertmanagerserver/server.go
index 457bb34826..5fccd0cc54 100644
--- a/pkg/alertmanager/alertmanagerserver/server.go
+++ b/pkg/alertmanager/alertmanagerserver/server.go
@@ -157,7 +157,7 @@ func New(ctx context.Context, logger *slog.Logger, registry prometheus.Registere
return 0, err
}
- return c, server.stateStore.Set(ctx, server.orgID, storableSilences)
+ return c, server.stateStore.Set(ctx, storableSilences)
})
}()
@@ -186,7 +186,7 @@ func New(ctx context.Context, logger *slog.Logger, registry prometheus.Registere
return 0, err
}
- return c, server.stateStore.Set(ctx, server.orgID, storableNFLog)
+ return c, server.stateStore.Set(ctx, storableNFLog)
})
}()
diff --git a/pkg/alertmanager/alertmanagerstore/sqlalertmanagerstore/state.go b/pkg/alertmanager/alertmanagerstore/sqlalertmanagerstore/state.go
index 5c4e6acefa..43bc348ac7 100644
--- a/pkg/alertmanager/alertmanagerstore/sqlalertmanagerstore/state.go
+++ b/pkg/alertmanager/alertmanagerstore/sqlalertmanagerstore/state.go
@@ -40,7 +40,7 @@ func (store *state) Get(ctx context.Context, orgID string) (*alertmanagertypes.S
}
// Set implements alertmanagertypes.StateStore.
-func (store *state) Set(ctx context.Context, orgID string, storeableState *alertmanagertypes.StoreableState) error {
+func (store *state) Set(ctx context.Context, storeableState *alertmanagertypes.StoreableState) error {
tx, err := store.sqlstore.BunDB().BeginTx(ctx, nil)
if err != nil {
return err
@@ -55,7 +55,6 @@ func (store *state) Set(ctx context.Context, orgID string, storeableState *alert
Set("silences = EXCLUDED.silences").
Set("nflog = EXCLUDED.nflog").
Set("updated_at = EXCLUDED.updated_at").
- Where("org_id = ?", orgID).
Exec(ctx)
if err != nil {
return err
diff --git a/pkg/types/alertmanagertypes/alertmanagertypestest/state.go b/pkg/types/alertmanagertypes/alertmanagertypestest/state.go
index a98a148ee8..c635941de7 100644
--- a/pkg/types/alertmanagertypes/alertmanagertypestest/state.go
+++ b/pkg/types/alertmanagertypes/alertmanagertypestest/state.go
@@ -21,9 +21,9 @@ func NewStateStore() *StateStore {
}
}
-func (s *StateStore) Set(ctx context.Context, orgID string, storeableState *alertmanagertypes.StoreableState) error {
+func (s *StateStore) Set(ctx context.Context, storeableState *alertmanagertypes.StoreableState) error {
s.mtx.Lock()
- s.states[orgID] = storeableState
+ s.states[storeableState.OrgID] = storeableState
s.mtx.Unlock()
return nil
}
diff --git a/pkg/types/alertmanagertypes/state.go b/pkg/types/alertmanagertypes/state.go
index f944d8392d..d431bed72b 100644
--- a/pkg/types/alertmanagertypes/state.go
+++ b/pkg/types/alertmanagertypes/state.go
@@ -104,7 +104,7 @@ type StateStore interface {
// The return type matches the return of `silence.Maintenance` or `nflog.Maintenance`.
// See https://github.com/prometheus/alertmanager/blob/3b06b97af4d146e141af92885a185891eb79a5b0/silence/silence.go#L217
// and https://github.com/prometheus/alertmanager/blob/3b06b97af4d146e141af92885a185891eb79a5b0/nflog/nflog.go#L94
- Set(context.Context, string, *StoreableState) error
+ Set(context.Context, *StoreableState) error
// Gets the silence state or the notification log state as a string from the store. This is used as a snapshot to load the
// initial state of silences or notification log when starting the alertmanager.