Skip to content

Commit 1122d94

Browse files
feat: add cluster to alerts description (when possible)
1 parent bdbf7f4 commit 1122d94

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

alerts/kube_apiserver.libsonnet

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ local utils = import '../lib/utils.libsonnet';
5959
severity: 'warning',
6060
},
6161
annotations: {
62-
description: 'A client certificate used to authenticate to kubernetes apiserver is expiring in less than %s.' % (utils.humanizeSeconds($._config.certExpirationWarningSeconds)),
62+
description: 'A client certificate used to authenticate to kubernetes apiserver is expiring in less than %s%s.' % [
63+
(utils.humanizeSeconds($._config.certExpirationWarningSeconds)),
64+
utils.ifClusterLabelSet($._config, ' on cluster {{ $labels.%(clusterLabel)s }}' % $._config),
65+
],
6366
summary: 'Client certificate is about to expire.',
6467
},
6568
},
@@ -75,7 +78,10 @@ local utils = import '../lib/utils.libsonnet';
7578
severity: 'critical',
7679
},
7780
annotations: {
78-
description: 'A client certificate used to authenticate to kubernetes apiserver is expiring in less than %s.' % (utils.humanizeSeconds($._config.certExpirationCriticalSeconds)),
81+
description: 'A client certificate used to authenticate to kubernetes apiserver is expiring in less than %s%s.' % [
82+
(utils.humanizeSeconds($._config.certExpirationCriticalSeconds)),
83+
utils.ifClusterLabelSet($._config, ' on cluster {{ $labels.%(clusterLabel)s }}' % $._config),
84+
],
7985
summary: 'Client certificate is about to expire.',
8086
},
8187
},

lib/utils.libsonnet

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,8 @@
5656
metric: labels.metric,
5757
},
5858
},
59+
60+
// if clusterLabel is set, return the string, otherwise return an empty string
61+
ifClusterLabelSet(config, string)::
62+
if std.length(config.clusterLabel) > 0 then string else '',
5963
}

0 commit comments

Comments
 (0)