Skip to content

Commit

Permalink
Merge pull request #1 from mr-yum/blunt-patch-for-kafka-exporter
Browse files Browse the repository at this point in the history
Comment out consumerGroupMembers metric which is causing exporter instability
  • Loading branch information
moogzy authored Sep 29, 2021
2 parents e8cd9a9 + 139477b commit 2f69036
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .promu.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
repository:
path: github.com/danielqsj/kafka_exporter
path: github.com/mr-yum/kafka_exporter
build:
flags: -a -tags netgo
ldflags: |
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
FROM quay.io/prometheus/busybox:latest
MAINTAINER Daniel Qian <[email protected]>

ARG TARGETARCH
ARG BIN_DIR=.build/linux-${TARGETARCH}/
ARG BIN_DIR=.build/linux-${TARGETARCH}

COPY ${BIN_DIR}/kafka_exporter /bin/kafka_exporter

Expand Down
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pkgs = $(shell $(GO) list ./... | grep -v /vendor/)

PREFIX ?= $(shell pwd)
BIN_DIR ?= $(shell pwd)
DOCKER_IMAGE_NAME ?= kafka-exporter
DOCKER_IMAGE_NAME ?= ghcr.io/mr-yum/kafka-exporter
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
TAG := $(shell echo `if [ "$(TRAVIS_BRANCH)" = "master" ] || [ "$(TRAVIS_BRANCH)" = "" ] ; then echo "latest"; else echo $(TRAVIS_BRANCH) ; fi`)

Expand Down Expand Up @@ -45,13 +45,12 @@ tarball: promu

docker: build
@echo ">> building docker image"
@docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" --build-arg BIN_DIR=. .
@docker build -t "$(DOCKER_IMAGE_NAME):latest" --build-arg BIN_DIR=. .

push: crossbuild
@echo ">> building and pushing multi-arch docker images, $(DOCKER_USERNAME),$(DOCKER_IMAGE_NAME),$(TAG)"
@docker login -u $(DOCKER_USERNAME) -p $(DOCKER_PASSWORD)
@echo ">> building and pushing multi-arch docker images, mr-yum,$(DOCKER_IMAGE_NAME),latest"
@docker buildx create --use
@docker buildx build -t "$(DOCKER_USERNAME)/$(DOCKER_IMAGE_NAME):$(TAG)" \
@docker buildx build -t "$(DOCKER_IMAGE_NAME):latest" \
--output "$(PUSHTAG)" \
--platform "$(DOCKER_PLATFORMS)" \
.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/danielqsj/kafka_exporter
module github.com/mr-yum/kafka_exporter

go 1.17

Expand Down
24 changes: 15 additions & 9 deletions kafka_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ var (
consumergroupLag *prometheus.Desc
consumergroupLagSum *prometheus.Desc
consumergroupLagZookeeper *prometheus.Desc
consumergroupMembers *prometheus.Desc
// TODO(adrian.arumugam): Hack to patch kafka_exporter to make it reliable ASAP while
// a better upstream patch is figured out.
//consumergroupMembers *prometheus.Desc
)

// Exporter collects Kafka stats from the given server and exports them using
Expand Down Expand Up @@ -573,9 +575,11 @@ func (e *Exporter) collect(ch chan<- prometheus.Metric) {
}
}
}
ch <- prometheus.MustNewConstMetric(
consumergroupMembers, prometheus.GaugeValue, float64(len(group.Members)), group.GroupId,
)
// TODO(adrian.arumugam): Hack to patch kafka_exporter to make it reliable ASAP while
// a better upstream patch is figured out.
//ch <- prometheus.MustNewConstMetric(
// consumergroupMembers, prometheus.GaugeValue, float64(len(group.Members)), group.GroupId,
//)
offsetFetchResponse, err := broker.FetchOffset(&offsetFetchRequest)
if err != nil {
glog.Errorf("Cannot get offset of group %s: %v", group.GroupId, err)
Expand Down Expand Up @@ -855,11 +859,13 @@ func setup(
[]string{"consumergroup", "topic"}, labels,
)

consumergroupMembers = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "consumergroup", "members"),
"Amount of members in a consumer group",
[]string{"consumergroup"}, labels,
)
// TODO(adrian.arumugam): Hack to patch kafka_exporter to make it reliable ASAP while
// a better upstream patch is figured out.
// consumergroupMembers = prometheus.NewDesc(
// prometheus.BuildFQName(namespace, "consumergroup", "members"),
// "Amount of members in a consumer group",
// []string{"consumergroup"}, labels,
// )

if logSarama {
sarama.Logger = log.New(os.Stdout, "[sarama] ", log.LstdFlags)
Expand Down

0 comments on commit 2f69036

Please sign in to comment.