Skip to content

Commit d6464a7

Browse files
authored
Merge pull request #9 from Lispython/feature/prometheus
Add prometheus metrics and exporter to topics observer
2 parents d18e103 + 7e40284 commit d6464a7

File tree

13 files changed

+1983
-247
lines changed

13 files changed

+1983
-247
lines changed

Cargo.lock

Lines changed: 954 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ env_logger = "0.7.1"
3030
futures = "0.3.0"
3131
byte-unit = "4.0.6"
3232
pretty-bytes = "0.2.2"
33+
prometheus = "0.9.0"
34+
lazy_static = "1.4.0"
35+
actix-web = "2.0.0"
36+
actix-rt = "1.1.1"
37+
ctrlc = "3.1.5"
3338

3439

3540
[profile.dev]
@@ -47,7 +52,6 @@ path = "src/lib.rs"
4752
name = "kafka-replicator"
4853
path = "src/main.rs"
4954

50-
5155
[[bin]]
5256
name = "kafka-producer"
5357
path = "src/producer.rs"

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM rust:1.44.1
1+
FROM rust:1.45.0
22

33

44
RUN apt-get update -y && apt-get install -y \

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
shell:
2-
docker-compose -f docker-compose.yml run --rm --use-aliases --service-ports app /bin/bash
2+
docker-compose -f docker-compose.yml run --rm --use-aliases app /bin/bash
33

44
build:
55
docker-compose -f docker-compose.yml build
@@ -8,7 +8,7 @@ build:
88
replicator:
99
# docker-compose -f docker-compose.yml run --rm --service-ports app cargo run --bin=replicator --verbose -- --config=fixtures/example_config.toml -p 9445 -h 0.0.0.0
1010

11-
docker-compose -f docker-compose.yml run --rm --use-aliases --service-ports app cargo run --bin=replicator --verbose -- examples/example_config.toml
11+
docker-compose -f docker-compose.yml run --rm --use-aliases app cargo run --bin=kafka-replicator --verbose -- examples/example-config.yaml
1212

1313
up:
1414
docker-compose -f docker-compose.yml up --rm

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Lets start with an overview of features that exist in kafka-replicator:
1414
* [x] **Flexible topic selection:** Select topics with configurable config;
1515
* [ ] **Auto-create topics:** Destination topics are automatically created for strict_p2p strategy;
1616
* [x] **Stats:** The tool shows replication status;
17-
* [ ] **Monitoring:** Kafka replicator exports stats via prometheus.
17+
* [x] **Monitoring:** Kafka replicator exports stats via prometheus.
1818
* [ ] **Cycle detection**
1919

2020

@@ -105,7 +105,7 @@ routes:
105105
downstream_topic: 'topic2'
106106
repartitioning_strategy: random # strict_p2p | random
107107
upstream_group_id: group_22
108-
progress_every_secs: 10
108+
show_progress_interval_secs: 10
109109
limits:
110110
messages_per_sec: 10000
111111
number_of_messages:
@@ -117,7 +117,7 @@ routes:
117117
downstream_topic: 'topic2'
118118
repartitioning_strategy: strict_p2p
119119
upstream_group_id: group_22
120-
progress_every_secs: 10
120+
show_progress_interval_secs: 10
121121

122122
- upstream_client: cl_2_client_1
123123
downstream_client: cl_1_client_1
@@ -127,28 +127,30 @@ routes:
127127
repartitioning_strategy: strict_p2p # strict_p2p | random
128128
default_begin_offset: earliest # optional
129129
upstream_group_id: group_2
130-
progress_every_secs: 10
130+
show_progress_interval_secs: 10
131131

132132

133133
observers:
134134
- client: cl_1_client_1
135135
name: "my name"
136-
topics:
136+
group_id: group_name # used for remaining metrics
137+
topics: # filter by topics
137138
- 'topic1'
138139
- 'topic2'
139-
fetch_timeout_secs: 5
140-
show_progress_every_secs: 10
140+
fetch_timeout_secs: 5 # default: 5
141+
fetch_interval_secs: 5 # default: 60
142+
show_progress_interval_secs: 10 # default: 60
141143

142144
- client: cl_2_client_1
143145
topic: 'topic3'
144146
topics:
145147
- 'topic2'
146-
show_progress_every_secs: 5
148+
show_progress_interval_secs: 5
147149

148150

149151
- client: cl_1_client_1
150152
topic: 'topic1'
151-
topics: []
153+
topics: [] # fetch all topics
152154
```
153155
154156

examples/example-config.yml

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
clusters:
22
- name: cluster_1
33
hosts:
4-
- replicator-kafka-1:9092
5-
- replicator-kafka-1:9092
4+
#- replicator-kafka-1:9092
5+
#- replicator-kafka-1:9092
66
- kafka_replicator_replicator_kafka_1_1:9092
77
- name: cluster_2
88
hosts:
99
- kafka_replicator_replicator_kafka_2_1:9092
10-
- replicator-kafka-2:9092
10+
#- replicator-kafka-2:9092
1111

1212
clients:
1313
- client: cl_1_client_1
@@ -19,14 +19,17 @@ clients:
1919
cluster: cluster_2
2020

2121
routes:
22-
- upstream_client: cl_1_client_1
23-
downstream_client: cl_1_client_1
24-
upstream_topics:
22+
- upstream_client: cl_1_client_1 # Required: source client name from clients section
23+
downstream_client: cl_1_client_1 # Required: target client name from clients section
24+
upstream_topics: # Required: source topics
2525
- 'topic1'
26-
downstream_topic: 'topic2'
26+
downstream_topic: 'topic2' # Required: target topics
2727
repartitioning_strategy: random # strict_p2p | random
28-
upstream_group_id: group_22
29-
progress_every_secs: 10
28+
upstream_group_id: group_22 # Option: upstream consumer group id
29+
show_progress_interval_secs: 2 # Optional: interval between console output
30+
update_metrics_interval_secs: 1 # Optional: interval between prometheus metrics updates
31+
upstream_poll_interval_ms: 200 # Optional: interval between upstream poll calls
32+
name: route_name # Optional:
3033
limits:
3134
messages_per_sec: 10000
3235
number_of_messages:
@@ -38,7 +41,7 @@ routes:
3841
downstream_topic: 'topic2'
3942
repartitioning_strategy: random # strict_p2p | random
4043
upstream_group_id: group_22
41-
progress_every_secs: 10
44+
show_progress_interval_secs: 10
4245

4346
- upstream_client: cl_2_client_1
4447
downstream_client: cl_1_client_1
@@ -48,25 +51,31 @@ routes:
4851
repartitioning_strategy: strict_p2p # strict_p2p | random
4952
default_begin_offset: earliest # optional
5053
upstream_group_id: group_2
51-
progress_every_secs: 10
54+
show_progress_interval_secs: 10
5255

5356

5457
observers:
5558
- client: cl_1_client_1
56-
name: "my name"
59+
name: "Observer name"
60+
group_id: group_22
5761
topics:
5862
- 'topic1'
59-
- 'topic2'
60-
fetch_timeout_secs: 5
61-
show_progress_every_secs: 10
63+
# - 'topic2'
64+
fetch_timeout_secs: 5 # default: 5
65+
fetch_interval_secs: 60 # default:
66+
show_progress_interval_secs: 10 # default: 60
6267

6368
- client: cl_2_client_1
64-
topic: 'topic3'
69+
# group_id: group_2
6570
topics:
6671
- 'topic2'
67-
show_progress_every_secs: 5
68-
72+
show_progress_interval_secsy: 20
6973

7074
- client: cl_1_client_1
71-
topic: 'topic1'
72-
topics: []
75+
topics: [] # process all topics
76+
77+
prometheus:
78+
# namespace: "app:observer:" # custom prometheus metrics prefix
79+
labels:
80+
label_key: label_value
81+
env: prod

examples/experiment-1.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ observers:
3939
- 'experimental_topic_1'
4040
- 'experimental_topic_2_output'
4141
fetch_timeout_secs: 5
42-
show_progress_every_secs: 10
42+
show_progress_interval_secs: 10

0 commit comments

Comments
 (0)