Files
karma/internal/transform/strip.go
Łukasz Mierzwa 5d4ae47888 Convert all packages to be internal
Internal packages are supported by Go 1.5+, any package in /internal/ dir is only importable from the same repo. This will cleanup main dir a bit and provide better namespace for unsee subpackages
2017-08-04 16:21:27 -07:00

23 lines
701 B
Go

package transform
import (
"strings"
"github.com/cloudflare/unsee/internal/slices"
)
// StripLables allows filtering out some labels from alerts
// it takes the list of label keys to ignore and alert label map
// it will return label map without labels found on the ignore list
func StripLables(ignoredLabels []string, sourceLabels map[string]string) map[string]string {
labels := map[string]string{}
for label, value := range sourceLabels {
if !slices.StringInSlice(ignoredLabels, label) {
// strip leading and trailung space in label value
// this is to normalize values in case space is added by Alertmanager rules
labels[label] = strings.TrimSpace(value)
}
}
return labels
}