app/{vmalert,vmagent}: skip empty values in -remoteWrite.label and -label lists

This commit is contained in:
Aliaksandr Valialkin 2020-12-08 14:53:41 +02:00
parent 5454668709
commit b6b1b06d70
2 changed files with 6 additions and 0 deletions

View file

@ -65,6 +65,9 @@ type relabelConfigs struct {
func initLabelsGlobal() {
labelsGlobal = nil
for _, s := range *unparsedLabelsGlobal {
if len(s) == 0 {
continue
}
n := strings.IndexByte(s, '=')
if n < 0 {
logger.Fatalf("missing '=' in `-remoteWrite.label`. It must contain label in the form `name=value`; got %q", s)

View file

@ -160,6 +160,9 @@ func newManager(ctx context.Context) (*manager, error) {
manager.rr = rr
for _, s := range *externalLabels {
if len(s) == 0 {
continue
}
n := strings.IndexByte(s, '=')
if n < 0 {
return nil, fmt.Errorf("missing '=' in `-label`. It must contain label in the form `name=value`; got %q", s)