diff --git a/cortex-mixin/alerts/alerts.libsonnet b/cortex-mixin/alerts/alerts.libsonnet index 42c1e5f7..3c407b48 100644 --- a/cortex-mixin/alerts/alerts.libsonnet +++ b/cortex-mixin/alerts/alerts.libsonnet @@ -1,4 +1,9 @@ { + // simpleRegexpOpt produces a simple regexp that matches all strings in the input array. + local simpleRegexpOpt(strings) = + assert std.isArray(strings) : 'simpleRegexpOpt requires that `strings` is an array of strings`'; + '(' + std.join('|', strings) + ')', + groups+: [ { name: 'cortex_alerts', @@ -590,11 +595,12 @@ rules: [ { alert: 'CortexGossipMembersMismatch', - expr: ||| - memberlist_client_cluster_members_count - != on (%s) group_left - sum by (%s) (up{job=~".+/(admin-api|compactor|store-gateway|distributor|ingester.*|querier.*|cortex|ruler)"}) - ||| % [$._config.alert_aggregation_labels, $._config.alert_aggregation_labels], + expr: + ||| + memberlist_client_cluster_members_count + != on (%s) group_left + sum by (%s) (up{job=~".+/%s"}) + ||| % [$._config.alert_aggregation_labels, $._config.alert_aggregation_labels, simpleRegexpOpt($._config.job_names.ring_members)], 'for': '5m', labels: { severity: 'warning', diff --git a/cortex-mixin/config.libsonnet b/cortex-mixin/config.libsonnet index 94de5dd7..9b8d81a2 100644 --- a/cortex-mixin/config.libsonnet +++ b/cortex-mixin/config.libsonnet @@ -33,6 +33,7 @@ query_frontend: '(query-frontend.*|cortex$)', // Match also custom query-frontend deployments. query_scheduler: 'query-scheduler.*', // Not part of single-binary. Match also custom query-scheduler deployments. table_manager: '(table-manager|cortex$)', + ring_members: ['compactor', 'distributor', 'ingester.*', 'querier.*', 'ruler', 'store-gateway', 'cortex'], store_gateway: '(store-gateway|cortex$)', gateway: '(gateway|cortex-gw|cortex-gw-internal)', compactor: 'compactor.*', // Match also custom compactor deployments.