-
Notifications
You must be signed in to change notification settings - Fork 1
Add persistent relabeled alerts rules #5
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
Add persistent relabeled alerts rules #5
Conversation
Signed-off-by: machadovilaca <machadovilaca@gmail.com>
Signed-off-by: machadovilaca <machadovilaca@gmail.com>
Signed-off-by: machadovilaca <machadovilaca@gmail.com>
Signed-off-by: machadovilaca <machadovilaca@gmail.com>
Signed-off-by: machadovilaca <machadovilaca@gmail.com>
| // Generate SHA256 hash | ||
| hash := sha256.Sum256([]byte(hashInput)) | ||
|
|
||
| return fmt.Sprintf("%s;%x", name, hash) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cant comment on lines that didn't change for some reason.. since now the seperator is ; need to update func (c *client) applyLabelChangesViaAlertRelabelConfig in update_platform_alert_rule.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thanks
pkg/k8s/relabeled_rules.go
Outdated
|
|
||
| configMapClient := rrm.clientset.CoreV1().ConfigMaps(ClusterMonitoringNamespace) | ||
|
|
||
| if err := configMapClient.Delete(ctx, RelabeledRulesConfigMapName, metav1.DeleteOptions{}); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check if ConfigMap exists or ignore not found error, in case it's fresh deployment or retry (delete succeeds but create fails) it will not get to the create and fail here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| } | ||
|
|
||
| originalRule, err := c.getOriginalPlatformRule(ctx, prId, alertRuleId) | ||
| originalRule, err := c.getOriginalPlatformRule(ctx, namespace, name, rule.Labels[k8s.AlertRuleLabelId]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why you use rule.Labels[k8s.AlertRuleLabelId] and not alertRuleId ?
I mean they should be same right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, same same
pkg/k8s/relabeled_rules.go
Outdated
| if rule.Alert == "TestRelabelAlert" { | ||
| for _, config := range relabelConfigs { | ||
| log.Infof("TestRelabelAlert relabel config: %+v", config) | ||
| } | ||
|
|
||
| log.Infof("TestRelabelAlert Relabeled alert %s from %s/%s with %d relabel configs", rule.Alert, promRule.Namespace, promRule.Name, len(relabelConfigs)) | ||
| log.Infof("TestRelabelAlert Original labels: %v", rule.Labels) | ||
| log.Infof("TestRelabelAlert Relabeled labels: %v", relabeledLabels.Map()) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we use hardcoded alert name in this file?
maybe set a debug flag or try to make the test work without it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed, used for debug
| "k8s.io/apimachinery/pkg/types" | ||
|
|
||
| "github.com/openshift/monitoring-plugin/pkg/management/mapper" | ||
| "github.com/openshift/monitoring-plugin/pkg/k8s" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't comment on lines that didn't added in this pr, but noticed in this file in func (c *client) buildRelabelConfigs
why we dont use Action: "LabelDrop" here:
case "LabelDrop":
config := osmv1.RelabelConfig{
SourceLabels: []osmv1.LabelName{"alertname"},
Regex: alertName,
TargetLabel: change.sourceLabel,
Replacement: "",
Action: "Replace",
}
Replacement with empty string will not drop the label right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create an issue to fix please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean in jira?
| } | ||
|
|
||
| go rrm.prometheusRulesInformer.Run(ctx.Done()) | ||
| go rrm.secretInformer.Run(ctx.Done()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add go rrm.configMapInformer.Run(ctx.Done()) to start the configMap informer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
|
|
||
| cache.WaitForNamedCacheSync("RelabeledRulesConfig informer", ctx.Done(), | ||
| rrm.prometheusRulesInformer.HasSynced, | ||
| rrm.secretInformer.HasSynced, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add rrm.configMapInformer.HasSynced
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
Signed-off-by: machadovilaca <machadovilaca@gmail.com>
Signed-off-by: machadovilaca <machadovilaca@gmail.com>
2ac914a to
63dffd3
Compare
No description provided.