Skip to content
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

feat: add cluster to alerts description (when possible) #988

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 8 additions & 2 deletions alerts/kube_apiserver.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ local utils = import '../lib/utils.libsonnet';
severity: 'warning',
},
annotations: {
description: 'A client certificate used to authenticate to kubernetes apiserver is expiring in less than %s.' % (utils.humanizeSeconds($._config.certExpirationWarningSeconds)),
description: 'A client certificate used to authenticate to kubernetes apiserver is expiring in less than %s%s.' % [
(utils.humanizeSeconds($._config.certExpirationWarningSeconds)),
utils.ifClusterLabelSet($._config, ' on cluster {{ $labels.%(clusterLabel)s }}' % $._config),
],
summary: 'Client certificate is about to expire.',
},
},
Expand All @@ -75,7 +78,10 @@ local utils = import '../lib/utils.libsonnet';
severity: 'critical',
},
annotations: {
description: 'A client certificate used to authenticate to kubernetes apiserver is expiring in less than %s.' % (utils.humanizeSeconds($._config.certExpirationCriticalSeconds)),
description: 'A client certificate used to authenticate to kubernetes apiserver is expiring in less than %s%s.' % [
(utils.humanizeSeconds($._config.certExpirationCriticalSeconds)),
utils.ifClusterLabelSet($._config, ' on cluster {{ $labels.%(clusterLabel)s }}' % $._config),
],
summary: 'Client certificate is about to expire.',
},
},
Expand Down
4 changes: 4 additions & 0 deletions lib/utils.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@
metric: labels.metric,
},
},

// if clusterLabel is set, return the string, otherwise return an empty string
ifClusterLabelSet(config, string)::
if std.length(config.clusterLabel) > 0 then string else '',
lorenzofelletti marked this conversation as resolved.
Show resolved Hide resolved
}