2022-09-07 20:18:00 +03:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2023-08-08 18:31:48 +03:00
|
|
|
"github.com/AdguardTeam/golibs/mapsutil"
|
2022-09-07 20:18:00 +03:00
|
|
|
"github.com/prometheus/common/model"
|
|
|
|
)
|
|
|
|
|
2023-03-18 17:11:10 +03:00
|
|
|
// Additional prometheus information configuration
|
|
|
|
|
2022-09-07 20:18:00 +03:00
|
|
|
// additionalInfo is a extra info configuration.
|
|
|
|
type additionalInfo map[string]string
|
|
|
|
|
|
|
|
// validateAdditionalInfo return an error is the section is invalid.
|
|
|
|
func (c additionalInfo) validate() (err error) {
|
2023-08-08 18:31:48 +03:00
|
|
|
return mapsutil.OrderedRangeError(c, func(k, _ string) (keyErr error) {
|
2023-03-18 17:11:10 +03:00
|
|
|
if model.LabelName(k).IsValid() {
|
|
|
|
return nil
|
2022-09-07 20:18:00 +03:00
|
|
|
}
|
|
|
|
|
2023-03-18 17:11:10 +03:00
|
|
|
return fmt.Errorf("prometheus labels must match %s, got %q", model.LabelNameRE, k)
|
|
|
|
})
|
2022-09-07 20:18:00 +03:00
|
|
|
}
|