diff --git a/pkg/services/ngalert/state/historian/core.go b/pkg/services/ngalert/state/historian/core.go index 4423cb401e5..c84d18b2a7d 100644 --- a/pkg/services/ngalert/state/historian/core.go +++ b/pkg/services/ngalert/state/historian/core.go @@ -57,14 +57,19 @@ type PanelKey struct { panelID int64 } +func NewPanelKey(orgID int64, dashUID string, panelID int64) PanelKey { + return PanelKey{ + orgID: orgID, + dashUID: dashUID, + panelID: panelID, + } +} + // PanelKey attempts to get the key of the panel attached to the given rule. Returns nil if the rule is not attached to a panel. func parsePanelKey(rule history_model.RuleMeta, logger log.Logger) *PanelKey { if rule.DashboardUID != "" { - return &PanelKey{ - orgID: rule.OrgID, - dashUID: rule.DashboardUID, - panelID: rule.PanelID, - } + key := NewPanelKey(rule.OrgID, rule.DashboardUID, rule.PanelID) + return &key } return nil }