diff --git a/alerts/kube_apiserver.libsonnet b/alerts/kube_apiserver.libsonnet index 7f4ced3dc..558c2acd2 100644 --- a/alerts/kube_apiserver.libsonnet +++ b/alerts/kube_apiserver.libsonnet @@ -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.', }, }, @@ -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.', }, }, diff --git a/lib/utils.libsonnet b/lib/utils.libsonnet index 512d6e68f..934c11875 100644 --- a/lib/utils.libsonnet +++ b/lib/utils.libsonnet @@ -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 '', }