Skip to content
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
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM scratch
ADD kafka-offset-exporter /
EXPOSE 9000
ENTRYPOINT ["/kafka-offset-exporter"]
CMD ["-brokers", "127.0.0.1:9092", "-topics", "^[^_].*", "-groups", "."]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should change -groups argument to '.*' otherwise no consumer-groups will match the pattern and therefore their stats will not be published but topic oldest/youngest offsets will still work, so you may not immediately notice.

27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,30 @@ Usage of ./kafka-offset-exporter:
-topics string
Only fetch offsets for topics matching this regex (default all)
```

## Dockerfile

First build the binary to include in the Docker container. Default this generates a 10M binary. With (optional) `-ldflags="-s -w"` it becomes 6.5M.
```
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" .
```

Optional optimization: final result 1.7M binary.
```
upx --ultra-brute kafka-offset-exporter
```

Now build the docker image:
```
docker build -t kafka-offset-exporter .
```

Run the image:
```
docker run -d -p 9000:9000 kafka-offset-exporter
```

Additionally add arguments, e.g.:
```
docker run -d -p 9000:9000 kafka-offset-exporter -brokers 127.0.0.1:9092
```