8000 feat(api): Add alert path prefix as configuration field by deadlycoconuts · Pull Request #648 · caraml-dev/merlin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(api): Add alert path prefix as configuration field #648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2025
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: 1 addition & 1 deletion api/cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func buildDependencies(ctx context.Context, cfg *config.Config, db *gorm.DB, dis
modelEndpointAlertService := service.NewModelEndpointAlertService(
storage.NewAlertStorage(db), gitlabClient, wardenClient,
gitlabConfig.DashboardRepository, gitlabConfig.DashboardBranch,
gitlabConfig.AlertRepository, gitlabConfig.AlertBranch,
gitlabConfig.AlertRepository, gitlabConfig.AlertBranch, gitlabConfig.AlertPathPrefix,
cfg.FeatureToggleConfig.MonitoringConfig.MonitoringBaseURL)

mlflowConfig := cfg.MlflowConfig
Expand Down
1 change: 1 addition & 0 deletions api/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ type GitlabConfig struct {
DashboardBranch string `default:"master"`
AlertRepository string
AlertBranch string `default:"master"`
AlertPathPrefix string
}

type WardenConfig struct {
Expand Down
3 changes: 2 additions & 1 deletion api/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,9 @@ func TestLoad(t *testing.T) {
BaseURL: "https://test.io/",
DashboardRepository: "dashboards/merlin",
DashboardBranch: "master",
AlertRepository: "alerts/merlin",
AlertRepository: "alerts_repository/merlin",
AlertBranch: "master",
AlertPathPrefix: "alerts/merlin",
},
WardenConfig: WardenConfig{
APIHost: "https://test.io/",
Expand Down
3 changes: 2 additions & 1 deletion api/config/testdata/base-configs-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ FeatureToggleConfig:
BaseURL: https://test.io/
DashboardRepository: dashboards/merlin
DashboardBranch: master
AlertRepository: alerts/merlin
AlertRepository: alerts_repository/merlin
AlertBranch: master
AlertPathPrefix: alerts/merlin
WardenConfig:
APIHost: https://test.io/
ModelDeletionConfig:
Expand Down
8 changes: 5 additions & 3 deletions api/service/model_endpoint_alert_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type modelEndpointAlertService struct {
dashboardBranch string
alertRepository string
alertBranch string
alertPathPrefix string

dashboardBaseURL string
}
Expand All @@ -53,7 +54,7 @@ func NewModelEndpointAlertService(
alertStorage storage.AlertStorage,
gitlabClient gitlab.Client, wardenClient warden.Client,
dashboardRepository, dashboardBranch,
alertRepository, alertBranch, dashboardBaseURL string) ModelEndpointAlertService {
alertRepository, alertBranch, alertPathPrefix, dashboardBaseURL string) ModelEndpointAlertService {
return &modelEndpointAlertService{
alertStorage: alertStorage,
gitlabClient: gitlabClient,
Expand All @@ -63,6 +64,7 @@ func NewModelEndpointAlertService(
dashboardBranch: dashboardBranch,
alertRepository: alertRepository,
alertBranch: alertBranch,
alertPathPrefix: alertPathPrefix,

dashboardBaseURL: dashboardBaseURL,
}
Expand Down Expand Up @@ -91,7 +93,7 @@ func (s *modelEndpointAlertService) CreateModelEndpointAlert(user string, alert
if err != nil {
return nil, err
}
alertFilename := fmt.Sprintf("alerts/merlin/%s/%s_%s.yaml", alert.Model.Project.Name, alert.Model.Name, alert.EnvironmentName)
alertFilename := fmt.Sprintf("%s/%s/%s_%s.yaml", s.alertPathPrefix, alert.Model.Project.Name, alert.Model.Name, alert.EnvironmentName)

createAlertOpt := gitlab.CreateFileOptions{
Repository: s.alertRepository,
Expand Down Expand Up @@ -125,7 +127,7 @@ func (s *modelEndpointAlertService) UpdateModelEndpointAlert(user string, alert
if err != nil {
return nil, err
}
alertFilename := fmt.Sprintf("alerts/merlin/%s/%s_%s.yaml", alert.Model.Project.Name, alert.Model.Name, alert.EnvironmentName)
alertFilename := fmt.Sprintf("%s/%s/%s_%s.yaml", s.alertPathPrefix, alert.Model.Project.Name, alert.Model.Name, alert.EnvironmentName)

updateAlertOpt := gitlab.UpdateFileOptions{
Repository: s.alertRepository,
Expand Down
Loading
0