mirror of
https://github.com/prymitive/karma
synced 2026-05-09 03:36:44 +00:00
Merge pull request #196 from loverend/add_REMOVE_RECEIVERS
Add REMOVE_RECEIVERS option
This commit is contained in:
15
README.md
15
README.md
@@ -409,6 +409,21 @@ This option can also be set using `-strip.labels` flag. Example:
|
||||
|
||||
This variable is optional and default is not set (all labels will be shown).
|
||||
|
||||
#### STRIP_RECEIVERS
|
||||
|
||||
List of receiver names that should not be shown on the UI. This allows to hide
|
||||
all alerts for receivers that are not needed on the alert dashboard. Accepts
|
||||
space separated list of receiver names. Examples:
|
||||
|
||||
STRIP_RECEIVERS=hipchat-test
|
||||
STRIP_RECEIVERS="hipchat-test blackhole"
|
||||
|
||||
This option can also be set using `-strip.receivers` flag. Example:
|
||||
|
||||
$ unsee -strip.receivers "hipchat-test blackhole"
|
||||
|
||||
This variable is optional and default is not set (all receivers will be shown).
|
||||
|
||||
#### WEB_PREFIX
|
||||
|
||||
URL root for unsee, you can use to if you wish to serve it from location other
|
||||
|
||||
@@ -63,6 +63,11 @@ func DedupAlerts() []models.AlertGroup {
|
||||
ag := models.AlertGroup(agList[0])
|
||||
ag.Alerts = models.AlertList{}
|
||||
for _, alert := range alerts {
|
||||
// remove all alerts for receiver(s) that the user doesn't
|
||||
// want to see in the UI
|
||||
if transform.StripReceivers(config.Config.StripReceivers, alert.Receiver) {
|
||||
continue
|
||||
}
|
||||
// strip labels user doesn't want to see in the UI
|
||||
alert.Labels = transform.StripLables(config.Config.KeepLabels, config.Config.StripLabels, alert.Labels)
|
||||
// calculate final alert state based on the most important value found
|
||||
|
||||
@@ -39,6 +39,7 @@ type configEnvs struct {
|
||||
SentryDSN string `envconfig:"SENTRY_DSN" help:"Sentry DSN for Go exceptions"`
|
||||
SentryPublicDSN string `envconfig:"SENTRY_PUBLIC_DSN" help:"Sentry DSN for javascript exceptions"`
|
||||
StripLabels spaceSeparatedList `envconfig:"STRIP_LABELS" help:"List of labels to ignore"`
|
||||
StripReceivers spaceSeparatedList `envconfig:"STRIP_RECEIVERS" help:"List of receivers to not display alerts for"`
|
||||
KeepLabels spaceSeparatedList `envconfig:"KEEP_LABELS" help:"List of labels to keep, all other labels will be stripped"`
|
||||
WebPrefix string `envconfig:"WEB_PREFIX" default:"/" help:"URL prefix"`
|
||||
}
|
||||
|
||||
@@ -26,3 +26,13 @@ func StripLables(keptLabels, ignoredLabels []string, sourceLabels map[string]str
|
||||
}
|
||||
return labels
|
||||
}
|
||||
|
||||
// StripReceivers allows filtering all alerts for specified receiver(s)
|
||||
func StripReceivers(ignoredReceivers []string, alertReceiver string) bool {
|
||||
for _, ignoredReceiver := range ignoredReceivers {
|
||||
if alertReceiver == ignoredReceiver {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user