Skip to content

Commit

Permalink
feat: add cluster to alerts description (when possible) (#988)
Browse files Browse the repository at this point in the history
* feat: add cluster to alerts description (when possible)

* feat: use showMultiCluster instead of cluster label
  • Loading branch information
lorenzofelletti authored Nov 25, 2024
1 parent bdbf7f4 commit 72a1a23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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.ifShowMultiCluster($._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.ifShowMultiCluster($._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 showMultiCluster is true in config, return the string, otherwise return an empty string
ifShowMultiCluster(config, string)::
if config.showMultiCluster then string else '',
}

0 comments on commit 72a1a23

Please sign in to comment.