mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Merge pull request #1996 from ton31337/Fix/allow_numbers_as_first_letter
Allow number to be the first letter as well for `job_name`
This commit is contained in:
commit
874cb44bb6
|
@ -28,7 +28,6 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
patJobName = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_-]*$`)
|
||||
patFileSDName = regexp.MustCompile(`^[^*]*(\*[^/]*)?\.(json|yml|yaml|JSON|YML|YAML)$`)
|
||||
patRulePath = regexp.MustCompile(`^[^*]*(\*[^/]*)?$`)
|
||||
patAuthLine = regexp.MustCompile(`((?:password|bearer_token|secret_key|client_secret):\s+)(".+"|'.+'|[^\s]+)`)
|
||||
|
@ -463,8 +462,8 @@ func (c *ScrapeConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||
if err := checkOverflow(c.XXX, "scrape_config"); err != nil {
|
||||
return err
|
||||
}
|
||||
if !patJobName.MatchString(c.JobName) {
|
||||
return fmt.Errorf("%q is not a valid job name", c.JobName)
|
||||
if len(c.JobName) == 0 {
|
||||
return fmt.Errorf("job_name is empty")
|
||||
}
|
||||
if len(c.BearerToken) > 0 && len(c.BearerTokenFile) > 0 {
|
||||
return fmt.Errorf("at most one of bearer_token & bearer_token_file must be configured")
|
||||
|
|
|
@ -307,6 +307,40 @@ var expectedConf = &Config{
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
JobName: "0123service-xxx",
|
||||
|
||||
ScrapeInterval: model.Duration(15 * time.Second),
|
||||
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
|
||||
|
||||
MetricsPath: DefaultScrapeConfig.MetricsPath,
|
||||
Scheme: DefaultScrapeConfig.Scheme,
|
||||
|
||||
StaticConfigs: []*TargetGroup{
|
||||
{
|
||||
Targets: []model.LabelSet{
|
||||
{model.AddressLabel: "localhost:9090"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
JobName: "測試",
|
||||
|
||||
ScrapeInterval: model.Duration(15 * time.Second),
|
||||
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
|
||||
|
||||
MetricsPath: DefaultScrapeConfig.MetricsPath,
|
||||
Scheme: DefaultScrapeConfig.Scheme,
|
||||
|
||||
StaticConfigs: []*TargetGroup{
|
||||
{
|
||||
Targets: []model.LabelSet{
|
||||
{model.AddressLabel: "localhost:9090"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
original: "",
|
||||
}
|
||||
|
@ -351,7 +385,7 @@ var expectedErrors = []struct {
|
|||
}{
|
||||
{
|
||||
filename: "jobname.bad.yml",
|
||||
errMsg: `"prom^etheus" is not a valid job name`,
|
||||
errMsg: `job_name is empty`,
|
||||
}, {
|
||||
filename: "jobname_dup.bad.yml",
|
||||
errMsg: `found multiple scrape configs with job name "prometheus"`,
|
||||
|
|
12
config/testdata/conf.good.yml
vendored
12
config/testdata/conf.good.yml
vendored
|
@ -142,3 +142,15 @@ scrape_configs:
|
|||
- localhost
|
||||
paths:
|
||||
- /monitoring
|
||||
|
||||
- job_name: 0123service-xxx
|
||||
metrics_path: /metrics
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost:9090
|
||||
|
||||
- job_name: 測試
|
||||
metrics_path: /metrics
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost:9090
|
||||
|
|
2
config/testdata/jobname.bad.yml
vendored
2
config/testdata/jobname.bad.yml
vendored
|
@ -1,2 +1,2 @@
|
|||
scrape_configs:
|
||||
- job_name: prom^etheus
|
||||
- job_name:
|
||||
|
|
Loading…
Reference in a new issue