Alerting: Return extra alertmanager config as a string for mimirtool (#106959)
This commit is contained in:
@@ -605,18 +605,14 @@ func (srv *ConvertPrometheusSrv) RouteConvertPrometheusGetAlertmanagerConfig(c *
|
||||
return response.Error(http.StatusNotFound, "Alertmanager configuration not found", nil)
|
||||
}
|
||||
|
||||
// Parse the configuration into our Gettable struct which will automatically
|
||||
// sanitize secrets and exclude global settings when marshaled back to YAML.
|
||||
var prometheusConfig amconfig.Config
|
||||
if err := yaml.Unmarshal([]byte(extraCfg.AlertmanagerConfig), &prometheusConfig); err != nil {
|
||||
sanitizedConfig, err := extraCfg.GetSanitizedAlertmanagerConfigYAML()
|
||||
if err != nil {
|
||||
return response.Error(http.StatusBadRequest, "Invalid Alertmanager configuration format", err)
|
||||
}
|
||||
|
||||
respBody := apimodels.GettableAlertmanagerUserConfig{
|
||||
AlertmanagerConfig: apimodels.GettableAlertmanagerConfig{
|
||||
Config: prometheusConfig,
|
||||
},
|
||||
TemplateFiles: extraCfg.TemplateFiles,
|
||||
respBody := apimodels.AlertmanagerUserConfig{
|
||||
AlertmanagerConfig: sanitizedConfig,
|
||||
TemplateFiles: extraCfg.TemplateFiles,
|
||||
}
|
||||
|
||||
resp := response.YAML(http.StatusOK, respBody)
|
||||
|
||||
Reference in New Issue
Block a user