diff --git a/internal/app/generate/generate.go b/internal/app/generate/generate.go index 273d1a48a17304094ae4d00ac2f216ed14a515a7..e9dff27773182d6657ef91636b1a5c3564819095 100644 --- a/internal/app/generate/generate.go +++ b/internal/app/generate/generate.go @@ -175,7 +175,7 @@ func (s Service) Generate(ctx context.Context, r Request) (*Response, error) { slo.Labels = utilsdata.MergeLabels(slo.Labels, r.ExtraLabels) // Generate SLO result. - result, err := s.generateSLO(ctx, r.Info, slo) + result, err := s.generateSLO(ctx, r.Info, r.SLOGroup, slo) if err != nil { return nil, fmt.Errorf("could not generate %q slo: %w", slo.ID, err) } @@ -188,7 +188,7 @@ func (s Service) Generate(ctx context.Context, r Request) (*Response, error) { }, nil } -func (s Service) generateSLO(ctx context.Context, info model.Info, slo model.PromSLO) (*model.PromSLORules, error) { +func (s Service) generateSLO(ctx context.Context, info model.Info, sloGroup model.PromSLOGroup, slo model.PromSLO) (*model.PromSLORules, error) { logger := s.logger.WithCtxValues(ctx).WithValues(log.Kv{"slo": slo.ID}) // Generate the MWMB alerts. @@ -242,6 +242,7 @@ func (s Service) generateSLO(ctx context.Context, info model.Info, slo model.Pro Info: info, MWMBAlertGroup: *as, SLO: slo, + SLOGroup: sloGroup, } res := &SLOProcessorResult{} for _, p := range sloProcessors { diff --git a/internal/app/generate/process.go b/internal/app/generate/process.go index 0dba86ea9c2f882ff5a310cb3aad415442eb2189..33de3e7e6f36aebfa73cedbb4259eae713c4f81a 100644 --- a/internal/app/generate/process.go +++ b/internal/app/generate/process.go @@ -13,6 +13,7 @@ import ( type SLOProcessorRequest struct { Info model.Info SLO model.PromSLO + SLOGroup model.PromSLOGroup MWMBAlertGroup model.MWMBAlertGroup } type SLOProcessorResult struct { @@ -51,6 +52,7 @@ func NewSLOProcessorFromSLOPluginV1(pluginFactory pluginslov1.PluginFactory, log Info: req.Info, SLO: req.SLO, MWMBAlertGroup: req.MWMBAlertGroup, + OriginalSource: req.SLOGroup.OriginalSource, } rs := &pluginslov1.Result{ SLORules: res.SLORules, diff --git a/pkg/prometheus/plugin/slo/v1/v1.go b/pkg/prometheus/plugin/slo/v1/v1.go index 2881f81b0f4190781133a61fb157bd9190f5b291..9d1118a2e7ea96a213b5658a9525c9f2ea56224f 100644 --- a/pkg/prometheus/plugin/slo/v1/v1.go +++ b/pkg/prometheus/plugin/slo/v1/v1.go @@ -29,6 +29,10 @@ type AppUtils struct { type Request struct { // Info about the application and execution, normally used as metadata. Info model.Info + // OriginalSource is the original specification of the SLO came from, this is informative data that + // can be used to make decision on plugins, it should be used only as RO. + // The information used on the generation is the SLO model itself not this one. + OriginalSource model.PromSLOGroupSource // The SLO to process and generate the final Prom rules. SLO model.PromSLO // The SLO MWMBAlertGroup selected.