fix: apply app-label-alias to shipped events
The alias was only ever used to build the `include_labels` filter on the generated vector source, while dokku labels containers with `com.dokku.app-name` unconditionally. Setting the property therefore pointed the source at a label no container carries, and log collection stopped without any error. The source now always filters the label dokku applies, and a generated remap renames the field on its way to the sink, which is what the property was documented to do. An app whose own alias differs from the global one gets a branch in the global pipeline, so a per-app value is honored even when the app ships through the global sink. Closes #8916.
This commit is contained in:
@@ -3,6 +3,7 @@ package logs
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -10,6 +11,10 @@ import (
|
||||
)
|
||||
|
||||
func validateSetValue(appName string, key string, value string) error {
|
||||
if key == "app-label-alias" {
|
||||
return validateAppLabelAlias(appName, value)
|
||||
}
|
||||
|
||||
if key == "max-size" {
|
||||
return validateMaxSize(appName, value)
|
||||
}
|
||||
@@ -29,6 +34,22 @@ func validateSetValue(appName string, key string, value string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// appLabelAliasPattern matches label keys that are safe to both use as a docker
|
||||
// label and quote into the generated vector remap program
|
||||
var appLabelAliasPattern = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9_.-]*$`)
|
||||
|
||||
func validateAppLabelAlias(appName string, value string) error {
|
||||
if value == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
if !appLabelAliasPattern.MatchString(value) {
|
||||
return errors.New("Invalid app-label-alias value, must start with a letter or number and contain only letters, numbers, and any of [_, ., -]")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateMaxSize(appName string, value string) error {
|
||||
if value == "" {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user