Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Conall Prendergast committed Jan 2, 2024
1 parent 1eb2685 commit 6b88aa2
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions controllers/absence_prometheusrule.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,20 @@ const absencePromRuleNameSuffix = "-absent-metric-alert-rules"
// holds the absence alert rules concerning a specific Prometheus server (e.g. openstack, kubernetes, etc.).
func AbsencePrometheusRuleName(prometheusRule monitoringv1.PrometheusRule, prometheusRuleString string) string {

//fmt.Printf("%+v\n", prometheusRule)

t := template.Must(template.New("sampleTest").Parse(prometheusRuleString))
t := template.Must(template.New("PrometheusRuleTemplate").Parse(prometheusRuleString))
b, err := json.Marshal(prometheusRule)

m := make(map[string]interface{})
err = json.Unmarshal(b, &m)

fmt.Println("After unmarshall")
fmt.Println(m)

buf := &bytes.Buffer{}
//err := t.Execute(buf, prometheusRule)
err = t.Execute(buf, m)
if err != nil {
fmt.Println(err.Error())
return "default-absent-metrics"
}


fmt.Println("Generated absence rule name:")
fmt.Println(buf.String())
return buf.String()

//return fmt.Sprintf("%s%s", promServer, absencePromRuleNameSuffix)
}

func (r *PrometheusRuleReconciler) newAbsencePrometheusRule(namespace, name string, promServer string) *monitoringv1.PrometheusRule {
Expand Down Expand Up @@ -240,9 +229,6 @@ func (r *PrometheusRuleReconciler) cleanUpAbsencePrometheusRule(ctx context.Cont
// concerning Prometheus server.
var listOpts client.ListOptions
client.InNamespace(absencePromRule.GetNamespace()).ApplyToList(&listOpts)
//client.MatchingLabels{
// labelPrometheusServer: absencePromRule.Labels[labelPrometheusServer],
//}.ApplyToList(&listOpts)
var promRules monitoringv1.PrometheusRuleList
if err := r.List(ctx, &promRules, &listOpts); err != nil {
return err
Expand Down

0 comments on commit 6b88aa2

Please sign in to comment.