Skip to content

Commit

Permalink
Merge branch 'master' into pr/allow-path-whitespaces
Browse files Browse the repository at this point in the history
* master: (23 commits)
  Cut release 0.7.0
  makefile: update Makefile.common with newer version
  Release 0.7.0-rc2
  Force Cache Init
  Release 0.7.0-rc1
  Updated dependencies - Updated client golang dependency. - Updated statsd mapper dependency. - Migrated current code to new statsd mapper library.
  Update main.go
  Fixed typo
  Fixed bad label value substitution
  Added more examples on how to use regex in names
  Fixed panic on bad runtime flags.
  Update changelog for prometheus#109 (prometheus#111)
  Update main.go
  fix comments
  run go mod vendor with go 1.13
  run go mod vendor
  fix invalid key
  switch logging to go-kit
  Fix go.mod and vendor/
  *: bump Go version to 1.13
  ...
  • Loading branch information
prosenkranz committed Mar 23, 2020
2 parents bab6616 + 9bac1e4 commit 8f46774
Show file tree
Hide file tree
Showing 365 changed files with 73,795 additions and 41,710 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Expand Up @@ -9,7 +9,7 @@ executors:
# should also be updated.
golang:
docker:
- image: circleci/golang:1.12
- image: circleci/golang:1.13

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion .promu.yml
@@ -1,7 +1,7 @@
go:
# Whenever the Go version is updated here, .travis.yml and
# .circle/config.yml should also be updated.
version: 1.12
version: 1.13
repository:
path: github.com/prometheus/graphite_exporter
build:
Expand Down
27 changes: 18 additions & 9 deletions CHANGELOG.md
@@ -1,4 +1,13 @@
# 0.6.2 / 2019-06-03
## 0.7.0 / 2020-02-28

* [CHANGE] Update logging library and flags ([#109](https://github.com/prometheus/graphite_exporter/pull/109))
* [CHANGE] Updated prometheus golang client and statsd mapper dependency. ([#113](https://github.com/prometheus/graphite_exporter/pull/113))

This release updates several dependencies. Logging-related flags have changed.

The metric mapping library is now at the level of [statsd exporter 0.14.1](https://github.com/prometheus/statsd_exporter/blob/master/CHANGELOG.md#0141--2010-01-13), bringing in various performance improvements. See the statsd exporter changelog for the detailed changes.

## 0.6.2 / 2019-06-03

* [CHANGE] Do not run as root in the Docker container by default ([#85](https://github.com/prometheus/graphite_exporter/pull/85))
* [BUGFIX] Serialize processing of samples ([#94](https://github.com/prometheus/graphite_exporter/pull/94))
Expand All @@ -8,23 +17,23 @@ clients sent metrics simultaneously, or multiple metrics were sent in
individual UDP packets. It would manifest as duplicate metrics being exported
(0.4.x) or the metrics endpoint failing altogether (0.5.0).

# 0.5.0 / 2019-02-28
## 0.5.0 / 2019-02-28

* [ENHANCEMENT] Accept 'name' as a label ([#75](https://github.com/prometheus/graphite_exporter/pull/75))
* [BUGFIX] Update the mapper to fix captures being clobbered ([#77](https://github.com/prometheus/graphite_exporter/pull/77))
* [BUGFIX] Do not mask the pprof endpoints ([#67](https://github.com/prometheus/graphite_exporter/pull/67))
* [ENHANCEMENT] Accept 'name' as a label ([#75](https://github.com/prometheus/graphite_exporter/pull/75))

This release also pulls in a more recent version of the Prometheus client library with improved validation and performance.

# 0.4.2 / 2018-11-26
## 0.4.2 / 2018-11-26

* [BUGFIX] Fix segfault in mapper if mapping config is provided ([#63](https://github.com/prometheus/graphite_exporter/pull/63))

# 0.4.1 / 2018-11-23
## 0.4.1 / 2018-11-23

No changes.

# 0.4.0 / 2018-11-23
## 0.4.0 / 2018-11-23

* [ENHANCEMENT] Log incoming and parsed samples if debug logging is enabled ([#58](https://github.com/prometheus/graphite_exporter/pull/58))
* [ENHANCEMENT] Speed up glob matching ([#59](https://github.com/prometheus/graphite_exporter/pull/59))
Expand All @@ -35,7 +44,7 @@ is logged.

This major enhancement was contributed by Wangchong Zhou in [prometheus/statsd_exporter#157](https://github.com/prometheus/statsd_exporter/pulls/157).

# 0.3.0 / 2018-08-22
## 0.3.0 / 2018-08-22

This release contains two major breaking changes:

Expand All @@ -54,12 +63,12 @@ Regular expressions can be used to match on Graphite metric names beyond extract
* [FEATURE] Add pprof endpoint ([#33](https://github.com/prometheus/graphite_exporter/33))
* [BUGFIX] Accept whitespace around the Graphite protocol lines ([#53](https://github.com/prometheus/graphite_exporter/53))

# 0.2.0 / 2017-03-01
## 0.2.0 / 2017-03-01

* [FEATURE] Added flag to allow dropping of unmatched metrics
* [ENHANCEMENT] Logging changes and standardisation


# 0.1.0 / 2015-05-05
## 0.1.0 / 2015-05-05

Initial release.
24 changes: 18 additions & 6 deletions Makefile.common
Expand Up @@ -69,12 +69,21 @@ else
GO_BUILD_PLATFORM ?= $(GOHOSTOS)-$(GOHOSTARCH)
endif

GOTEST := $(GO) test
GOTEST_DIR :=
ifneq ($(CIRCLE_JOB),)
ifneq ($(shell which gotestsum),)
GOTEST_DIR := test-results
GOTEST := gotestsum --junitfile $(GOTEST_DIR)/unit-tests.xml --
endif
endif

PROMU_VERSION ?= 0.5.0
PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz

GOLANGCI_LINT :=
GOLANGCI_LINT_OPTS ?=
GOLANGCI_LINT_VERSION ?= v1.16.0
GOLANGCI_LINT_VERSION ?= v1.18.0
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64.
# windows isn't included here because of the path separator being different.
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))
Expand Down Expand Up @@ -142,14 +151,17 @@ else
endif

.PHONY: common-test-short
common-test-short:
common-test-short: $(GOTEST_DIR)
@echo ">> running short tests"
GO111MODULE=$(GO111MODULE) $(GO) test -short $(GOOPTS) $(pkgs)
GO111MODULE=$(GO111MODULE) $(GOTEST) -short $(GOOPTS) $(pkgs)

.PHONY: common-test
common-test:
common-test: $(GOTEST_DIR)
@echo ">> running all tests"
GO111MODULE=$(GO111MODULE) $(GO) test $(test-flags) $(GOOPTS) $(pkgs)
GO111MODULE=$(GO111MODULE) $(GOTEST) $(test-flags) $(GOOPTS) $(pkgs)

$(GOTEST_DIR):
@mkdir -p $@

.PHONY: common-format
common-format:
Expand Down Expand Up @@ -201,7 +213,7 @@ endif
.PHONY: common-build
common-build: promu
@echo ">> building binaries"
GO111MODULE=$(GO111MODULE) $(PROMU) build --prefix $(PREFIX)
GO111MODULE=$(GO111MODULE) $(PROMU) build --prefix $(PREFIX) $(PROMU_BINARIES)

.PHONY: common-tarball
common-tarball: promu
Expand Down
11 changes: 11 additions & 0 deletions README.md
Expand Up @@ -66,6 +66,12 @@ mappings:
job: ${1}_server
outcome: $3
provider: $2
- match: 'servers\.(.*)\.networking\.subnetworks\.transmissions\.([a-z0-9-]+)\.(.*)'
match_type: regex
name: 'servers_networking_transmissions_${3}'
labels:
hostname: ${1}
device: ${2}
```

This would transform these example graphite metrics into Prometheus metrics as
Expand All @@ -79,6 +85,11 @@ follows:

test.web-server.foo.bar
=> test_web__server_foo_bar{}

servers.rack-003-server-c4de.networking.subnetworks.transmissions.eth0.failure.mean_rate
=> servers_networking_transmissions_failure_mean_rate{device="eth0",hostname="rack-003-server-c4de"}



### Conversion from legacy configuration

Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.6.2
0.7.0
81 changes: 81 additions & 0 deletions e2e/e2e_test.go
Expand Up @@ -108,3 +108,84 @@ rspamd.spam_count 3 NOW`
}
}
}

func TestIssue111(t *testing.T) {
cwd, err := os.Getwd()
if err != nil {
t.Fatal(err)
}

webAddr, graphiteAddr := fmt.Sprintf("127.0.0.1:%d", 9108), fmt.Sprintf("127.0.0.1:%d", 9109)
exporter := exec.Command(
filepath.Join(cwd, "..", "graphite_exporter"),
"--web.listen-address", webAddr,
"--graphite.listen-address", graphiteAddr,
)
err = exporter.Start()
if err != nil {
t.Fatalf("execution error: %v", err)
}
defer exporter.Process.Kill()

for i := 0; i < 10; i++ {
if i > 0 {
time.Sleep(1 * time.Second)
}
resp, err := http.Get("http://" + webAddr)
if err != nil {
continue
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
break
}
}

now := time.Now()

input := `rspamd.actions.add_header 2 NOW
rspamd.actions.greylist 0 NOW
rspamd.actions.no_action 24 NOW
rspamd.actions.reject 1 NOW
rspamd.actions.rewrite_subject 0 NOW
rspamd.actions.soft_reject 0 NOW
rspamd.bytes_allocated 4165268944 NOW
rspamd.chunks_allocated 4294966730 NOW
rspamd.chunks_freed 0 NOW
rspamd.chunks_oversized 1 NOW
rspamd.connections 1 NOW
rspamd.control_connections 1 NOW
rspamd.ham_count 24 NOW
rspamd.learned 2 NOW
rspamd.pools_allocated 59 NOW
rspamd.pools_freed 171 NOW
rspamd.scanned 27 NOW
rspamd.shared_chunks_allocated 34 NOW
rspamd.spam_count 3 NOW`
input = strings.NewReplacer("NOW", fmt.Sprintf("%d", now.Unix())).Replace(input)

conn, err := net.Dial("tcp", graphiteAddr)
if err != nil {
t.Fatalf("connection error: %v", err)
}
defer conn.Close()
_, err = conn.Write([]byte(input))
if err != nil {
t.Fatalf("write error: %v", err)
}

resp, err := http.Get("http://" + path.Join(webAddr, "metrics"))
if err != nil {
t.Fatalf("get error: %v", err)
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
t.Fatalf("read error: %v", err)
}
for _, s := range []string{"rspamd_actions_add_header 2", "rspamd_connections 1"} {
if !strings.Contains(string(b), s) {
t.Fatalf("Expected %q in %q – input: %q – time: %s", s, string(b), input, now)
}
}
}
10 changes: 6 additions & 4 deletions go.mod
@@ -1,10 +1,12 @@
module github.com/prometheus/graphite_exporter

require (
github.com/prometheus/client_golang v1.0.0
github.com/prometheus/common v0.4.1
github.com/prometheus/statsd_exporter v0.8.1
github.com/sirupsen/logrus v1.4.2 // indirect
github.com/go-kit/kit v0.9.0
github.com/prometheus/client_golang v1.3.0
github.com/prometheus/common v0.7.0
github.com/prometheus/statsd_exporter v0.14.1
github.com/stretchr/testify v1.3.0
gopkg.in/alecthomas/kingpin.v2 v2.2.6
)

go 1.13

0 comments on commit 8f46774

Please sign in to comment.