Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/prometheus/prometheus int…
Browse files Browse the repository at this point in the history
…o update_k8s
  • Loading branch information
tariqibrahim committed Dec 4, 2018
2 parents e4222b1 + 11a52be commit 08d6c83
Show file tree
Hide file tree
Showing 46 changed files with 899 additions and 256 deletions.
10 changes: 5 additions & 5 deletions .promu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ build:
path: ./cmd/promtool
flags: -mod=vendor -a -tags netgo
ldflags: |
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Version={{.Version}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Revision={{.Revision}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Branch={{.Branch}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildUser={{user}}@{{host}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}}
-X github.com/prometheus/common/version.Version={{.Version}}
-X github.com/prometheus/common/version.Revision={{.Revision}}
-X github.com/prometheus/common/version.Branch={{.Branch}}
-X github.com/prometheus/common/version.BuildUser={{user}}@{{host}}
-X github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}}
tarball:
files:
- consoles
Expand Down
2 changes: 1 addition & 1 deletion MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Maintainers of this repository with their focus areas:

* Brian Brazil <brian.brazil@robustperception.io> @brian-brazil: Console templates; semantics of PromQL, service discovery, and relabeling.
* Fabian Reinartz <fabian.reinartz@coreos.com> @fabxc: PromQL parsing and evaluation; implementation of retrieval, alert notification, and service discovery.
* Fabian Reinartz <freinartz@google.com> @fabxc: PromQL parsing and evaluation; implementation of retrieval, alert notification, and service discovery.
* Julius Volz <julius.volz@gmail.com> @juliusv: Remote storage integrations; web UI.

8 changes: 5 additions & 3 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,11 @@ common-docker-tag-latest:
promu: $(PROMU)

$(PROMU):
curl -s -L $(PROMU_URL) | tar -xvz -C /tmp
mkdir -v -p $(FIRST_GOPATH)/bin
cp -v /tmp/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM)/promu $(PROMU)
$(eval PROMU_TMP := $(shell mktemp -d))
curl -s -L $(PROMU_URL) | tar -xvzf - -C $(PROMU_TMP)
mkdir -p $(FIRST_GOPATH)/bin
cp $(PROMU_TMP)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM)/promu $(FIRST_GOPATH)/bin/promu
rm -r $(PROMU_TMP)

.PHONY: proto
proto:
Expand Down
60 changes: 59 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
// Do global overrides and validate unique names.
jobNames := map[string]struct{}{}
for _, scfg := range c.ScrapeConfigs {
if scfg == nil {
return fmt.Errorf("empty or null scrape config section")
}
// First set the correct scrape interval, then check that the timeout
// (inferred or explicit) is not greater than that.
if scfg.ScrapeInterval == 0 {
Expand All @@ -254,6 +257,16 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
jobNames[scfg.JobName] = struct{}{}
}
for _, rwcfg := range c.RemoteWriteConfigs {
if rwcfg == nil {
return fmt.Errorf("empty or null remote write config section")
}
}
for _, rrcfg := range c.RemoteReadConfigs {
if rrcfg == nil {
return fmt.Errorf("empty or null remote read config section")
}
}
return nil
}

Expand Down Expand Up @@ -360,6 +373,13 @@ func (c *ScrapeConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
return err
}

// The UnmarshalYAML method of ServiceDiscoveryConfig is not being called because it's not a pointer.
// We cannot make it a pointer as the parser panics for inlined pointer structs.
// Thus we just do its validation here.
if err := c.ServiceDiscoveryConfig.Validate(); err != nil {
return err
}

// Check for users putting URLs in target groups.
if len(c.RelabelConfigs) == 0 {
for _, tg := range c.ServiceDiscoveryConfig.StaticConfigs {
Expand All @@ -371,6 +391,17 @@ func (c *ScrapeConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
}

for _, rlcfg := range c.RelabelConfigs {
if rlcfg == nil {
return fmt.Errorf("empty or null target relabeling rule in scrape config")
}
}
for _, rlcfg := range c.MetricRelabelConfigs {
if rlcfg == nil {
return fmt.Errorf("empty or null metric relabeling rule in scrape config")
}
}

// Add index to the static config target groups for unique identification
// within scrape pool.
for i, tg := range c.ServiceDiscoveryConfig.StaticConfigs {
Expand All @@ -392,7 +423,16 @@ func (c *AlertingConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
// by the default due to the YAML parser behavior for empty blocks.
*c = AlertingConfig{}
type plain AlertingConfig
return unmarshal((*plain)(c))
if err := unmarshal((*plain)(c)); err != nil {
return err
}

for _, rlcfg := range c.AlertRelabelConfigs {
if rlcfg == nil {
return fmt.Errorf("empty or null alert relabeling rule")
}
}
return nil
}

// AlertmanagerConfig configures how Alertmanagers can be discovered and communicated with.
Expand Down Expand Up @@ -429,6 +469,13 @@ func (c *AlertmanagerConfig) UnmarshalYAML(unmarshal func(interface{}) error) er
return err
}

// The UnmarshalYAML method of ServiceDiscoveryConfig is not being called because it's not a pointer.
// We cannot make it a pointer as the parser panics for inlined pointer structs.
// Thus we just do its validation here.
if err := c.ServiceDiscoveryConfig.Validate(); err != nil {
return err
}

// Check for users putting URLs in target groups.
if len(c.RelabelConfigs) == 0 {
for _, tg := range c.ServiceDiscoveryConfig.StaticConfigs {
Expand All @@ -440,6 +487,12 @@ func (c *AlertmanagerConfig) UnmarshalYAML(unmarshal func(interface{}) error) er
}
}

for _, rlcfg := range c.RelabelConfigs {
if rlcfg == nil {
return fmt.Errorf("empty or null Alertmanager target relabeling rule")
}
}

// Add index to the static config target groups for unique identification
// within scrape pool.
for i, tg := range c.ServiceDiscoveryConfig.StaticConfigs {
Expand Down Expand Up @@ -632,6 +685,11 @@ func (c *RemoteWriteConfig) UnmarshalYAML(unmarshal func(interface{}) error) err
if c.URL == nil {
return fmt.Errorf("url for remote_write is empty")
}
for _, rlcfg := range c.WriteRelabelConfigs {
if rlcfg == nil {
return fmt.Errorf("empty or null relabeling rule in remote write config")
}
}

// The UnmarshalYAML method of HTTPClientConfig is not being called because it's not a pointer.
// We cannot make it a pointer as the parser panics for inlined pointer structs.
Expand Down
52 changes: 52 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,58 @@ var expectedErrors = []struct {
filename: "section_key_dup.bad.yml",
errMsg: "field scrape_configs already set in type config.plain",
},
{
filename: "azure_client_id_missing.bad.yml",
errMsg: "Azure SD configuration requires a client_id",
},
{
filename: "azure_client_secret_missing.bad.yml",
errMsg: "Azure SD configuration requires a client_secret",
},
{
filename: "azure_subscription_id_missing.bad.yml",
errMsg: "Azure SD configuration requires a subscription_id",
},
{
filename: "azure_tenant_id_missing.bad.yml",
errMsg: "Azure SD configuration requires a tenant_id",
},
{
filename: "empty_scrape_config.bad.yml",
errMsg: "empty or null scrape config section",
},
{
filename: "empty_rw_config.bad.yml",
errMsg: "empty or null remote write config section",
},
{
filename: "empty_rr_config.bad.yml",
errMsg: "empty or null remote read config section",
},
{
filename: "empty_target_relabel_config.bad.yml",
errMsg: "empty or null target relabeling rule",
},
{
filename: "empty_metric_relabel_config.bad.yml",
errMsg: "empty or null metric relabeling rule",
},
{
filename: "empty_alert_relabel_config.bad.yml",
errMsg: "empty or null alert relabeling rule",
},
{
filename: "empty_alertmanager_relabel_config.bad.yml",
errMsg: "empty or null Alertmanager target relabeling rule",
},
{
filename: "empty_rw_relabel_config.bad.yml",
errMsg: "empty or null relabeling rule in remote write config",
},
{
filename: "empty_static_config.bad.yml",
errMsg: "empty or null section in static_configs",
},
}

func TestBadConfigs(t *testing.T) {
Expand Down
7 changes: 7 additions & 0 deletions config/testdata/azure_client_id_missing.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
scrape_configs:
- job_name: azure
azure_sd_configs:
- subscription_id: 11AAAA11-A11A-111A-A111-1111A1111A11
tenant_id: BBBB222B-B2B2-2B22-B222-2BB2222BB2B2
client_id:
client_secret: mysecret
7 changes: 7 additions & 0 deletions config/testdata/azure_client_secret_missing.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
scrape_configs:
- job_name: azure
azure_sd_configs:
- subscription_id: 11AAAA11-A11A-111A-A111-1111A1111A11
tenant_id: BBBB222B-B2B2-2B22-B222-2BB2222BB2B2
client_id: 333333CC-3C33-3333-CCC3-33C3CCCCC33C
client_secret:
7 changes: 7 additions & 0 deletions config/testdata/azure_subscription_id_missing.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
scrape_configs:
- job_name: azure
azure_sd_configs:
- subscription_id:
tenant_id: BBBB222B-B2B2-2B22-B222-2BB2222BB2B2
client_id: 333333CC-3C33-3333-CCC3-33C3CCCCC33C
client_secret: mysecret
7 changes: 7 additions & 0 deletions config/testdata/azure_tenant_id_missing.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
scrape_configs:
- job_name: azure
azure_sd_configs:
- subscription_id: 11AAAA11-A11A-111A-A111-1111A1111A11
tenant_id:
client_id: 333333CC-3C33-3333-CCC3-33C3CCCCC33C
client_secret: mysecret
3 changes: 3 additions & 0 deletions config/testdata/empty_alert_relabel_config.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alerting:
alert_relabel_configs:
-
4 changes: 4 additions & 0 deletions config/testdata/empty_alertmanager_relabel_config.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
alerting:
alertmanagers:
- relabel_configs:
-
4 changes: 4 additions & 0 deletions config/testdata/empty_metric_relabel_config.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
scrape_configs:
- job_name: "test"
metric_relabel_configs:
-
2 changes: 2 additions & 0 deletions config/testdata/empty_rr_config.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
remote_read:
-
2 changes: 2 additions & 0 deletions config/testdata/empty_rw_config.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
remote_write:
-
4 changes: 4 additions & 0 deletions config/testdata/empty_rw_relabel_config.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
remote_write:
- url: "foo"
write_relabel_configs:
-
2 changes: 2 additions & 0 deletions config/testdata/empty_scrape_config.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scrape_configs:
-
4 changes: 4 additions & 0 deletions config/testdata/empty_static_config.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
scrape_configs:
- job_name: "test"
static_configs:
-
4 changes: 4 additions & 0 deletions config/testdata/empty_target_relabel_config.bad.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
scrape_configs:
- job_name: "test"
relabel_configs:
-

0 comments on commit 08d6c83

Please sign in to comment.