Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new parameter "group" to filter alert rules #70

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ Flags:
-n, --name strings The name of one or more specific alerts to check.
This parameter can be repeated e.G.: '--name alert1 --name alert2'
If no name is given, all alerts will be evaluated
-g, --group strings The name of one or more specific groups to check.
This parameter can be repeated e.G.: '--group group1 --group group2'
If no group is given, all groups will be scanned for alerts
-T, --no-alerts-state string State to assign when no alerts are found (0, 1, 2, 3, OK, WARNING, CRITICAL, UNKNOWN). If not set this defaults to OK (default "OK")
-P, --problems Display only alerts which status is not inactive/OK. Note that in combination with the --name flag this might result in no alerts being displayed
```
Expand Down
7 changes: 6 additions & 1 deletion cmd/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ inactive = 0`,
}

// Get all rules from all groups into a single list
rules := alert.FlattenRules(alerts.Groups)
rules := alert.FlattenRules(alerts.Groups, cliAlertConfig.Group)

// If there are no rules we can exit early
if len(rules) == 0 {
Expand Down Expand Up @@ -217,6 +217,11 @@ func init() {
"\nThis parameter can be repeated e.G.: '--name alert1 --name alert2'"+
"\nIf no name is given, all alerts will be evaluated")

fs.StringSliceVarP(&cliAlertConfig.Group, "group", "g", nil,
"The name of one or more specific groups to check for alerts."+
"\nThis parameter can be repeated e.G.: '--group group1 --group group2'"+
"\nIf no group is given, all groups will be scanned for alerts")

fs.BoolVarP(&cliAlertConfig.ProblemsOnly, "problems", "P", false,
"Display only alerts which status is not inactive/OK. Note that in combination with the --name flag this might result in no alerts being displayed")
}
Expand Down
Loading