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

add grafana metric dashboard #91

Merged
merged 1 commit into from
Sep 5, 2024
Merged
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ All DCP-related metrics are automatically injected. It means you don't need to d
|--------------------| ---- |---- |-----------------|
| November 11, 2023 | November 11, 2023 | Creating connector via builder | Compile project |

## Grafana Metric Dashboard

[Grafana & Prometheus Example](example/grafana)

## Contributing

Go Dcp Kafka is always open for direct contributions. For more information please check
Expand Down
22 changes: 22 additions & 0 deletions example/grafana/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM golang:1.21-alpine AS builder

WORKDIR /project

COPY go.mod go.sum ./
COPY main.go ./
COPY config.yml ./config.yml

RUN go mod download
RUN CGO_ENABLED=0 go build -a -o example main.go

FROM alpine:3.17.1

WORKDIR /app

RUN apk --no-cache add ca-certificates

USER nobody
COPY --from=builder --chown=nobody:nobody /project/example .
COPY --from=builder --chown=nobody:nobody /project/config.yml ./config.yml

ENTRYPOINT ["./example"]
21 changes: 21 additions & 0 deletions example/grafana/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
hosts:
- couchbase:8091
username: user
password: password
bucketName: dcp-test
dcp:
group:
name: group-test
membership:
type: static
metadata:
type: couchbase
config:
bucket: dcp-test
scope: _default
collection: _default
kafka:
collectionTopicMapping:
_default: topic-test
brokers:
- redpanda:9092
6 changes: 6 additions & 0 deletions example/grafana/couchbase/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM couchbase:7.6.2

COPY configure.sh /opt/couchbase
RUN chmod +x /opt/couchbase/configure.sh

CMD ["/opt/couchbase/configure.sh"]
29 changes: 29 additions & 0 deletions example/grafana/couchbase/configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Start Couchbase server in background
/entrypoint.sh couchbase-server &

# Wait for Couchbase to start
sleep 10

# Setup cluster
couchbase-cli cluster-init -c 127.0.0.1:8091 \
--cluster-username user \
--cluster-password password \
--services data,index,query,fts,eventing,analytics \
--cluster-ramsize 1024 \
--cluster-index-ramsize 256 \
--cluster-fts-ramsize 256 \
--cluster-eventing-ramsize 256 \
--cluster-analytics-ramsize 1024

# Create a bucket
couchbase-cli bucket-create -c 127.0.0.1:8091 \
--username user \
--password password \
--bucket dcp-test \
--bucket-type couchbase \
--bucket-ramsize 256

# Keep the container running
tail -f /dev/null
90 changes: 90 additions & 0 deletions example/grafana/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
version: '3.9'

volumes:
prometheus_data: { }
grafana_data: { }

services:
go-dcp-kafka:
build: .
ports:
- "8080:8080"
expose:
- 8080
depends_on:
- couchbase
- redpanda

couchbase:
build: ./couchbase
ports:
- "8091-8094:8091-8094"
- "11210:11210"
expose:
- 8091
environment:
- COUCHBASE_ADMINISTRATOR_USERNAME=user
- COUCHBASE_ADMINISTRATOR_PASSWORD=password

redpanda:
image: docker.redpanda.com/redpandadata/redpanda
container_name: redpanda
command:
- redpanda
- start
- --smp
- '1'
- --reserve-memory
- 0M
- --overprovisioned
- --node-id
- '0'
- --kafka-addr
- PLAINTEXT://0.0.0.0:29092,OUTSIDE://0.0.0.0:9092
- --advertise-kafka-addr
- PLAINTEXT://redpanda:29092,OUTSIDE://localhost:9092
- --pandaproxy-addr
- PLAINTEXT://0.0.0.0:28082,OUTSIDE://0.0.0.0:8082
- --advertise-pandaproxy-addr
- PLAINTEXT://redpanda:28082,OUTSIDE://localhost:8082
ports:
- 8081:8081
- 8082:8082
- 9092:9092
- 28082:28082
- 29092:29092
redpanda-topic-create:
image: docker.redpanda.com/redpandadata/redpanda
container_name: redpanda-topic-create
entrypoint: [ "bash", "-c", "sleep 5 && rpk topic create topic-test --brokers redpanda:29092" ]
depends_on:
- redpanda
restart: "no"

prometheus:
image: prom/prometheus:v2.53.1
container_name: prometheus
volumes:
- ./prometheus:/etc/prometheus
- prometheus_data:/prometheus
ports:
- "9090:9090"
expose:
- 9090

grafana:
image: grafana/grafana:10.0.0
container_name: grafana
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning
environment:
- GF_AUTH_DISABLE_LOGIN_FORM=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
- GF_AUTH_ANONYMOUS_ENABLED=true
ports:
- "3000:3000"
expose:
- 3000
depends_on:
- prometheus
91 changes: 91 additions & 0 deletions example/grafana/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
module grafana

go 1.21

require (
github.com/Trendyol/go-dcp-kafka v1.1.51
github.com/couchbase/gocb/v2 v2.9.1
)

require (
github.com/Trendyol/go-dcp v1.1.50 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/ansrivas/fiberprometheus/v2 v2.6.1 // indirect
github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/couchbase/gocbcore/v10 v10.5.1 // indirect
github.com/couchbase/gocbcoreps v0.1.3 // indirect
github.com/couchbase/goprotostellar v1.0.2 // indirect
github.com/couchbaselabs/gocbconnstr/v2 v2.0.0-20240607131231-fb385523de28 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.3 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
github.com/go-openapi/jsonreference v0.20.4 // indirect
github.com/go-openapi/swag v0.22.9 // indirect
github.com/gofiber/adaptor/v2 v2.2.1 // indirect
github.com/gofiber/fiber/v2 v2.52.5 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mhmtszr/concurrent-swiss-map v1.0.8 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/segmentio/kafka-go v0.4.47 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.52.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.29.4 // indirect
k8s.io/apimachinery v0.29.4 // indirect
k8s.io/client-go v0.29.4 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading
Loading