Skip to content

Commit

Permalink
Make alert routing discovery output easier to review (#184)
Browse files Browse the repository at this point in the history
Sorts and deduplicates the namespaces.
  • Loading branch information
bastjan authored Oct 3, 2023
1 parent b430c60 commit e1cec6a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
13 changes: 8 additions & 5 deletions component/alert-routing-discovery.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ local ownerOrFallbackTeam =
params.openshift4_monitoring.fallback_team;

// teamToNS is a map from a team to namespaces.
local teamToNS = std.foldl(
function(prev, app)
prev { [prom.teamForApplication(app)]+: [ discoverNS(app) ] },
inv.applications,
{}
local teamToNS = std.mapWithKey(
function(_, a) std.uniq(std.sort(std.prune(a))),
std.foldl(
function(prev, app)
prev { [prom.teamForApplication(app)]+: [ discoverNS(app) ] },
inv.applications,
{}
)
);

// teamBasedRouting contains discovered routes for teams.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ stringData:
- "continue": true
"matchers":
- "syn_team = \"\""
- "namespace =~ \"ns-string|same-ns\""
- "namespace =~ \"ns-string\""
"receiver": "team_default_clumsy-donkeys"
- "continue": true
"matchers":
Expand All @@ -53,7 +53,7 @@ stringData:
- "continue": false
"matchers":
- "syn_team = \"\""
- "namespace =~ \"base|overridden|ns-string|same-ns|ns-object|same-ns\""
- "namespace =~ \"base|overridden|ns-string|ns-object|same-ns\""
"receiver": "__component_openshift4_monitoring_null"
- "matchers":
- "other = \"true\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data:
- "continue": true
"matchers":
- "syn_team = \"\""
- "namespace =~ \"ns-string|same-ns\""
- "namespace =~ \"ns-string\""
"receiver": "team_default_clumsy-donkeys"
- "continue": true
"matchers":
Expand All @@ -45,7 +45,7 @@ data:
- "continue": false
"matchers":
- "syn_team = \"\""
- "namespace =~ \"base|overridden|ns-string|same-ns|ns-object|same-ns\""
- "namespace =~ \"base|overridden|ns-string|ns-object|same-ns\""
"receiver": "__component_openshift4_monitoring_null"
- "matchers":
- "other = \"true\""
Expand Down Expand Up @@ -75,7 +75,7 @@ data:
"non-existing as still-non-existing": "clumsy-donkeys"
"ns-object": "lovable-lizards"
"ns-string": "clumsy-donkeys"
"same-ns-1": "clumsy-donkeys"
"same-ns-1": "lovable-lizards"
"same-ns-2": "lovable-lizards"
proposed_routes: |-
- "continue": true
Expand All @@ -86,7 +86,7 @@ data:
- "continue": true
"matchers":
- "syn_team = \"\""
- "namespace =~ \"ns-string|same-ns\""
- "namespace =~ \"ns-string\""
"receiver": "team_default_clumsy-donkeys"
- "continue": true
"matchers":
Expand All @@ -96,7 +96,7 @@ data:
- "continue": false
"matchers":
- "syn_team = \"\""
- "namespace =~ \"base|overridden|ns-string|same-ns|ns-object|same-ns\""
- "namespace =~ \"base|overridden|ns-string|ns-object|same-ns\""
"receiver": "__component_openshift4_monitoring_null"
kind: ConfigMap
metadata:
Expand Down
1 change: 1 addition & 0 deletions tests/team-routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ parameters:
lovable-lizards:
instances:
- ns-object
- same-ns-1
- same-ns-2
- ns-in-base
- ~ns-in-base
Expand Down

0 comments on commit e1cec6a

Please sign in to comment.