Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase on 0.12.0 #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 3 additions & 36 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,18 @@
---
version: 2.1

orbs:
prometheus: prometheus/prometheus@0.4.0

jobs:
test:
# Whenever the Go version is updated here, .promu.yml
# should also be updated.
docker:
- image: circleci/golang:1.15

working_directory: /go/src/github.com/FundingCircle/haproxy_exporter
steps:
- prometheus/setup_environment
- setup_remote_docker
- checkout
- run: make
- prometheus/store_artifact:
file: haproxy_exporter

workflows:
version: 2
haproxy_exporter:
jobs:
- test:
filters:
tags:
only: /.*/
- prometheus/build:
name: build
filters:
tags:
only: /.*/
- prometheus/publish_master:
context: org-context
requires:
- test
- build
filters:
branches:
only: master
- prometheus/publish_release:
context: org-context
requires:
- test
- build
filters:
tags:
only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
branches:
ignore: /.*/
- test
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @FundingCircle/platform-engineering
2 changes: 1 addition & 1 deletion .promu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ go:
# .circle/config.yml should also be updated.
version: 1.15
repository:
path: github.com/prometheus/haproxy_exporter
path: github.com/FundingCircle/haproxy_exporter
build:
flags: -mod=vendor -a -tags netgo
ldflags: |
Expand Down
18 changes: 0 additions & 18 deletions CONTRIBUTING.md

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG ARCH="amd64"
ARG OS="linux"
FROM quay.io/prometheus/busybox:latest
FROM quay.io/prometheus/busybox:latest
LABEL maintainer="The Prometheus Authors <prometheus-developers@googlegroups.com>"

ARG ARCH="amd64"
Expand Down
1 change: 0 additions & 1 deletion MAINTAINERS.md

This file was deleted.

43 changes: 33 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# HAProxy Exporter for Prometheus

Fork of https://github.com/prometheus/haproxy_exporter

This is a simple server that scrapes HAProxy stats and exports them via HTTP for
Prometheus consumption.

***Note:** since HAProxy 2.0.0, the official source includes a Prometheus exporter module that can be built into your binary with a single flag during build time and offers an exporter-free Prometheus endpoint. More information [down below](#official-prometheus-exporter).*
**\*Note:** since HAProxy 2.0.0, the official source includes a Prometheus exporter module that can be built into your binary with a single flag during build time and offers an exporter-free Prometheus endpoint. More information [down below](#official-prometheus-exporter).*

## Getting Started

Expand All @@ -19,11 +21,9 @@ Help on flags:
./haproxy_exporter --help
```

For more information check the [source code documentation][gdocs]. All of the
core developers are accessible via the Prometheus Developers [mailinglist][].
For more information check the [source code documentation][gdocs].

[gdocs]: http://godoc.org/github.com/prometheus/haproxy_exporter
[mailinglist]: https://groups.google.com/forum/?fromgroups#!forum/prometheus-developers
[gdocs]: https://godoc.org/github.com/FundingCircle/haproxy_exporter

## Usage

Expand Down Expand Up @@ -105,22 +105,45 @@ make build

### Testing

[![Build Status](https://travis-ci.org/prometheus/haproxy_exporter.png?branch=master)][travisci]
[![CircleCI](https://circleci.com/gh/prometheus/haproxy_exporter/tree/master.svg?style=shield)][circleci]
[![CircleCI](https://circleci.com/gh/FundingCircle/haproxy_exporter/tree/master.svg?style=shield)][circleci]

```bash
make test
```

[travisci]: https://travis-ci.org/prometheus/haproxy_exporter
[circleci]: https://circleci.com/gh/prometheus/haproxy_exporter
[circleci]: https://circleci.com/gh/FundingCircle/haproxy_exporter

### Releases

https://github.com/FundingCircle/haproxy_exporter/releases

0. Bump the VERSION file and merge to master
1. Create a tag and then create a release
2. Publish binaries:

```
git checkout <your-tag>

promu crossbuild
promu crossbuild tarballs

" You'll need
" brew install github-release
" export GITHUB_TOKEN=<your token from https://github.com/settings/tokens>

promu release -v .tarballs/
```

## License

Apache License 2.0, see [LICENSE](https://github.com/prometheus/haproxy_exporter/blob/master/LICENSE).
Apache License 2.0, see [prometheus/haproxy_exporter/LICENSE](https://github.com/prometheus/haproxy_exporter/blob/master/LICENSE), [FundingCircle/haproxy_exporter/LICENSE](https://github.com/FundingCircle/haproxy_exporter/blob/master/LICENSE).

## Alternatives

### Official Repo

https://github.com/prometheus/haproxy_exporter

### Official Prometheus exporter

As of 2.0.0, HAProxy includes a Prometheus exporter module that can be built into your binary during build time.
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/prometheus/haproxy_exporter
module github.com/FundingCircle/haproxy_exporter

go 1.14

Expand All @@ -11,3 +11,5 @@ require (
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6
)

go 1.13
7 changes: 4 additions & 3 deletions haproxy_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const (
pxnameField = 0
svnameField = 1
statusField = 17
sidField = 28
typeField = 32
checkDurationField = 38
qtimeMsField = 58
Expand All @@ -73,7 +74,7 @@ const (
var (
frontendLabelNames = []string{"frontend"}
backendLabelNames = []string{"backend"}
serverLabelNames = []string{"backend", "server"}
serverLabelNames = []string{"backend", "sid", "server"}
)

type metricInfo struct {
Expand Down Expand Up @@ -452,7 +453,7 @@ func (e *Exporter) parseRow(csvRow []string, ch chan<- prometheus.Metric) {
return
}

pxname, svname, status, typ := csvRow[pxnameField], csvRow[svnameField], csvRow[statusField], csvRow[typeField]
pxname, svname, status, sid, typ := csvRow[pxnameField], csvRow[svnameField], csvRow[statusField], csvRow[sidField], csvRow[typeField]

const (
frontend = "0"
Expand All @@ -468,7 +469,7 @@ func (e *Exporter) parseRow(csvRow []string, ch chan<- prometheus.Metric) {
case server:

if _, ok := e.excludedServerStates[status]; !ok {
e.exportCsvFields(e.serverMetrics, csvRow, ch, pxname, svname)
e.exportCsvFields(e.serverMetrics, csvRow, ch, pxname, sid, svname)
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions haproxy_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,26 @@ foo,BACKEND,0,0,0,0,,0,0,0,,0,,0,0,0,0,UP,1,1,0,0,0,5007,0,,1,8,1,,0,,2,
expectMetrics(t, e, "older_haproxy_versions.metrics")
}

func TestDuplicatedBackendServers(t *testing.T) {
const data = `service-0,FRONTEND,,,0,0,10000,0,0,0,0,0,0,,,,,OPEN,,,,,,,,,1,25,0,,,,0,0,0,0,,,,0,0,0,0,0,0,,0,0,0,,,0,0,0,0,,,,,,,,,,,,,,,,,,,,,http,,0,0,0,0,0,0,
service-0,service-0-server-0,0,0,0,0,,0,0,0,,0,,0,0,0,0,DOWN,1,1,0,0,1,135,135,,1,363,14908,,0,,2,0,,0,L4CON,,0,0,0,0,0,0,0,,,,,0,0,,,,,-1,Connection refused,,0,0,0,0,,,,Layer4 connection problem,,2,6,0,,,,,,http,,,,,,,,
service-0,service-0-server-1,0,0,0,0,,0,0,0,,0,,0,0,0,0,DOWN,1,1,0,1,1,135,135,,1,363,1498,,0,,2,0,,0,L4CON,,0,0,0,0,0,0,0,,,,,0,0,,,,,-1,Connection refused,,0,0,0,0,,,,Layer4 connection problem,,2,6,0,,,,,,http,,,,,,,,
service-0,service-0-server-1,0,0,0,0,,0,0,0,,0,,0,0,0,0,DOWN,1,1,0,0,1,135,135,,1,363,25913,,0,,2,0,,0,L4CON,,0,0,0,0,0,0,0,,,,,0,0,,,,,-1,Connection refused,,0,0,0,0,,,,Layer4 connection problem,,2,6,0,,,,,,http,,,,,,,,
service-0,service-0-server-1,0,0,0,0,,0,0,0,,0,,0,0,0,0,DOWN,1,1,0,1,1,135,135,,1,363,1200,,0,,2,0,,0,L4CON,,0,0,0,0,0,0,0,,,,,0,0,,,,,-1,Connection refused,,0,0,0,0,,,,Layer4 connection problem,,2,6,0,,,,,,http,,,,,,,,
service-0,service-0-server-1,0,0,0,0,,0,0,0,,0,,0,0,0,0,DOWN,1,1,0,0,1,135,135,,1,363,2371,,0,,2,0,,0,L4CON,,0,0,0,0,0,0,0,,,,,0,0,,,,,-1,Connection refused,,0,0,0,0,,,,Layer4 connection problem,,2,6,0,,,,,,http,,,,,,,,
service-0,service-0-server-2,0,0,0,0,,0,0,0,,0,,0,0,0,0,DOWN,1,1,0,1,1,135,135,,1,363,26277,,0,,2,0,,0,L4CON,,0,0,0,0,0,0,0,,,,,0,0,,,,,-1,Connection refused,,0,0,0,0,,,,Layer4 connection problem,,2,6,0,,,,,,http,,,,,,,,
service-0,service-0-server-3,0,0,0,0,,0,0,0,,0,,0,0,0,0,DOWN,1,1,0,0,1,135,135,,1,363,20477,,0,,2,0,,0,L4CON,,0,0,0,0,0,0,0,,,,,0,0,,,,,-1,Connection refused,,0,0,0,0,,,,Layer4 connection problem,,2,6,0,,,,,,http,,,,,,,,
service-0,BACKEND,0,0,0,0,3000,0,0,0,0,0,,0,0,0,0,DOWN,0,0,0,,1,134,134,,1,363,0,,0,,1,0,,0,,,,0,0,0,0,0,0,,,,0,0,0,0,0,0,0,-1,,,0,0,0,0,,,,,,,,,,,,,,http,,,,,,,,
`

h := newHaproxy([]byte(data))
defer h.Close()

e, _ := NewExporter(h.URL, true, serverMetrics, 5*time.Second, log.NewNopLogger())

expectMetrics(t, e, "duplicated_backend_servers.metrics")
}

func TestConfigChangeDetection(t *testing.T) {
h := newHaproxy([]byte(""))
defer h.Close()
Expand Down
Loading