-
Notifications
You must be signed in to change notification settings - Fork 5k
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
kube-state alert routing in multi tenant cluster #1231
Comments
hey guys, what do you think about this proposal. any input is highly appreciated. |
I just saw this request and I highly endorse it. In our company we have a similar setup via slack as described here and its currently not easy to route generic prometheus alerts to separate channels. |
You can use templates inside a label, in which you can execute a query. Support for additional labels is already present. I have used the following to apply the correct team/squad label to alerts that have a namespace label. In the defaultRules:
additionalRuleLabels:
squad: '{{ with printf `kube_namespace_labels{namespace="%s"}` .Labels.namespace | query }}{{ with (. | first).Labels.label_squad }}{{ . }}{{else}}nosquad{{end}}{{else}}nosquad{{end}}'
kube-state-metrics:
# make sure kube-state-metrics includes the label
metricLabelsAllowlist: namespaces=[squad] Each alert will get a squad label containing the squad that is defined in the namespace label. If no label is defined, the value will be nosquad. |
thanks @jorik90 , this is amazing. closing the issue. |
Hey guys,
I'm facing the following challenge. We are running a cluster with multiple tenant supporting their own workloads. Each tenant has a separate alerting channel, so we would need to route the alerts generated out of the kube-state-metrics based on the source namespaces. As far as I can tell, the current chart does not allow such a dynamic routing of the alerts based on the source namespace.
We came up with the following solution:
alerts
to each namespace representing the name of the channel where the alert are supposed to be routed to.kube_namespace_labels
metric, which contains all the labels attached to namespaces ( seelabel_alerts
)namespace
in order to get the value of thealerts
label of the namespace from step 1. , and use it as a label on the alert itselfThe problem is, that we need to copy/paste all the rules from the kube-state-metrics in order to add the grouping to the expressions
* on(namespace) group_left(label_alerts) kube_namespace_labels
and the parenthesis. I imagine others may face the same challenges, so I thought about adding 2 extra values like.Values.defaultRules.expressionPrefix
and.Values.defaultRules.expressionSuffix
to be able to feed the grouping into all the rules without copy/pasting and maintaining the rules ... so the rule would become something like:and the values:
Let me know please WDYT, or if you have another alternative to achieve the same goal.
Cheers,
Robert
The text was updated successfully, but these errors were encountered: