1 |
commit: 055ccb3adb8de2b369320233269445b126840928 |
2 |
Author: Manuel Rüger <mrueg <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Jan 18 16:01:10 2019 +0000 |
4 |
Commit: Manuel Rüger <mrueg <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Jan 18 16:01:56 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=055ccb3a |
7 |
|
8 |
app-metrics/burrow_exporter: Apply patch to provide correct metrics |
9 |
|
10 |
Package-Manager: Portage-2.3.56, Repoman-2.3.12 |
11 |
Signed-off-by: Manuel Rüger <mrueg <AT> gentoo.org> |
12 |
|
13 |
.../burrow_exporter-0.0.6-r1.ebuild | 62 +++++ |
14 |
.../files/burrow_exporter-0.0.6-fix-metrics.patch | 49 ++++ |
15 |
.../burrow_exporter-0.0.6-skippable-metrics.patch | 273 +++++++++++++++++++++ |
16 |
.../files/burrow_exporter.logrotated | 7 + |
17 |
4 files changed, 391 insertions(+) |
18 |
|
19 |
diff --git a/app-metrics/burrow_exporter/burrow_exporter-0.0.6-r1.ebuild b/app-metrics/burrow_exporter/burrow_exporter-0.0.6-r1.ebuild |
20 |
new file mode 100644 |
21 |
index 00000000000..b6a97d6ef8f |
22 |
--- /dev/null |
23 |
+++ b/app-metrics/burrow_exporter/burrow_exporter-0.0.6-r1.ebuild |
24 |
@@ -0,0 +1,62 @@ |
25 |
+# Copyright 1999-2019 Gentoo Authors |
26 |
+# Distributed under the terms of the GNU General Public License v2 |
27 |
+ |
28 |
+EAPI=6 |
29 |
+ |
30 |
+EGO_VENDOR=( |
31 |
+ "github.com/beorn7/perks 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9" |
32 |
+ "github.com/golang/protobuf 2bba0603135d7d7f5cb73b2125beeda19c09f4ef" |
33 |
+ "github.com/matttproud/golang_protobuf_extensions c12348ce28de40eed0136aa2b644d0ee0650e56c" |
34 |
+ "github.com/prometheus/client_golang 42552c195dd3f3089fbf9cf26e139da150af35aa" |
35 |
+ "github.com/prometheus/client_model 6f3806018612930941127f2a7c6c453ba2c527d2" |
36 |
+ "github.com/prometheus/common 13ba4ddd0caa9c28ca7b7bffe1dfa9ed8d5ef207" |
37 |
+ "github.com/prometheus/procfs 65c1f6f8f0fc1e2185eb9863a3bc751496404259" |
38 |
+ "github.com/Sirupsen/logrus ba1b36c82c5e05c4f912a88eab0dcd91a171688f" |
39 |
+ "github.com/urfave/cli ab403a54a148f2d857920810291539e1f817ee7b" |
40 |
+) |
41 |
+inherit user golang-build golang-vcs-snapshot |
42 |
+ |
43 |
+EGO_PN="github.com/jirwin/burrow_exporter" |
44 |
+EXPORTER_COMMIT="01f0ef9" |
45 |
+ARCHIVE_URI="https://${EGO_PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz" |
46 |
+KEYWORDS="~amd64" |
47 |
+ |
48 |
+DESCRIPTION="Prometheus exporter for Burrow" |
49 |
+HOMEPAGE="https://github.com/jirwin/burrow_exporter" |
50 |
+SRC_URI="${ARCHIVE_URI} |
51 |
+ ${EGO_VENDOR_URI}" |
52 |
+LICENSE="Apache-2.0" |
53 |
+SLOT="0" |
54 |
+IUSE="" |
55 |
+ |
56 |
+pkg_setup() { |
57 |
+ enewgroup ${PN} |
58 |
+ enewuser ${PN} -1 -1 -1 ${PN} |
59 |
+} |
60 |
+ |
61 |
+src_prepare() { |
62 |
+ pushd src/${EGO_PN} || die |
63 |
+ eapply "${FILESDIR}"/${P}-skippable-metrics.patch "${FILESDIR}"/${P}-fix-metrics.patch |
64 |
+ sed -i -e "s/0.0.5/${PV}/" burrow-exporter.go || die |
65 |
+ popd || die |
66 |
+ default |
67 |
+} |
68 |
+ |
69 |
+src_compile() { |
70 |
+ pushd src/${EGO_PN} || die |
71 |
+ GOPATH="${S}" go build -v -o bin/burrow_exporter || die |
72 |
+ popd || die |
73 |
+} |
74 |
+ |
75 |
+src_install() { |
76 |
+ pushd src/${EGO_PN} || die |
77 |
+ dobin bin/burrow_exporter |
78 |
+ dodoc README.md |
79 |
+ popd || die |
80 |
+ keepdir /var/log/burrow_exporter |
81 |
+ fowners ${PN}:${PN} /var/log/burrow_exporter |
82 |
+ newinitd "${FILESDIR}"/${PN}.initd ${PN} |
83 |
+ newconfd "${FILESDIR}"/${PN}.confd ${PN} |
84 |
+ insinto /etc/logrotate.d |
85 |
+ newins "${FILESDIR}/${PN}.logrotated" ${PN} |
86 |
+} |
87 |
|
88 |
diff --git a/app-metrics/burrow_exporter/files/burrow_exporter-0.0.6-fix-metrics.patch b/app-metrics/burrow_exporter/files/burrow_exporter-0.0.6-fix-metrics.patch |
89 |
new file mode 100644 |
90 |
index 00000000000..0d5a6f40dc7 |
91 |
--- /dev/null |
92 |
+++ b/app-metrics/burrow_exporter/files/burrow_exporter-0.0.6-fix-metrics.patch |
93 |
@@ -0,0 +1,49 @@ |
94 |
+From a40362c95ca5534040d8c29a23b40168a9d70015 Mon Sep 17 00:00:00 2001 |
95 |
+From: Guillaume Herail <guillaume@××××××.net> |
96 |
+Date: Wed, 16 Jan 2019 18:03:51 +0100 |
97 |
+Subject: [PATCH] fix(KafkaConsumerPartitionLag): Use proper current lag |
98 |
+ |
99 |
+Before this fix, the latest committed lag was used for the metric, it |
100 |
+now uses the current lag on the partition. |
101 |
+ |
102 |
+Fixes #26 |
103 |
+--- |
104 |
+ burrow_exporter/client.go | 11 ++++++----- |
105 |
+ burrow_exporter/exporter.go | 2 +- |
106 |
+ 2 files changed, 7 insertions(+), 6 deletions(-) |
107 |
+ |
108 |
+diff --git a/burrow_exporter/client.go b/burrow_exporter/client.go |
109 |
+index daaf84f..f4dc656 100644 |
110 |
+--- a/burrow_exporter/client.go |
111 |
++++ b/burrow_exporter/client.go |
112 |
+@@ -70,11 +70,12 @@ type ConsumerGroupStatus struct { |
113 |
+ } |
114 |
+ |
115 |
+ type Partition struct { |
116 |
+- Topic string `json:"topic"` |
117 |
+- Partition int32 `json:"partition"` |
118 |
+- Status string `json:"status"` |
119 |
+- Start Offset `json:"start"` |
120 |
+- End Offset `json:"end"` |
121 |
++ Topic string `json:"topic"` |
122 |
++ Partition int32 `json:"partition"` |
123 |
++ Status string `json:"status"` |
124 |
++ Start Offset `json:"start"` |
125 |
++ End Offset `json:"end"` |
126 |
++ CurrentLag int64 `json:"current_lag"` |
127 |
+ } |
128 |
+ |
129 |
+ type ConsumerGroupStatusResp struct { |
130 |
+diff --git a/burrow_exporter/exporter.go b/burrow_exporter/exporter.go |
131 |
+index 8b48b35..153ccbb 100644 |
132 |
+--- a/burrow_exporter/exporter.go |
133 |
++++ b/burrow_exporter/exporter.go |
134 |
+@@ -45,7 +45,7 @@ func (be *BurrowExporter) processGroup(cluster, group string) { |
135 |
+ "group": status.Status.Group, |
136 |
+ "topic": partition.Topic, |
137 |
+ "partition": strconv.Itoa(int(partition.Partition)), |
138 |
+- }).Set(float64(partition.End.Lag)) |
139 |
++ }).Set(float64(partition.CurrentLag)) |
140 |
+ } |
141 |
+ |
142 |
+ if !be.skipPartitionCurrentOffset { |
143 |
|
144 |
diff --git a/app-metrics/burrow_exporter/files/burrow_exporter-0.0.6-skippable-metrics.patch b/app-metrics/burrow_exporter/files/burrow_exporter-0.0.6-skippable-metrics.patch |
145 |
new file mode 100644 |
146 |
index 00000000000..1b9c84599eb |
147 |
--- /dev/null |
148 |
+++ b/app-metrics/burrow_exporter/files/burrow_exporter-0.0.6-skippable-metrics.patch |
149 |
@@ -0,0 +1,273 @@ |
150 |
+From 50db40e49750378e22e2b638754ff07ff29f5362 Mon Sep 17 00:00:00 2001 |
151 |
+From: NovaPS6 <NovaPS6@××××××××××××××××××.com> |
152 |
+Date: Wed, 8 Aug 2018 14:43:33 +0100 |
153 |
+Subject: [PATCH] make all metrics skippable |
154 |
+ |
155 |
+Change import back to jirwin |
156 |
+--- |
157 |
+ .gitignore | 1 + |
158 |
+ burrow-exporter.go | 67 +++++++++++++++++------ |
159 |
+ burrow_exporter/exporter.go | 102 +++++++++++++++++++++--------------- |
160 |
+ 3 files changed, 113 insertions(+), 57 deletions(-) |
161 |
+ |
162 |
+diff --git a/.gitignore b/.gitignore |
163 |
+index 502219c..a8e0d62 100644 |
164 |
+--- a/.gitignore |
165 |
++++ b/.gitignore |
166 |
+@@ -18,3 +18,4 @@ |
167 |
+ burrow-exporter |
168 |
+ dist/ |
169 |
+ vendor/ |
170 |
++.idea/ |
171 |
+diff --git a/burrow-exporter.go b/burrow-exporter.go |
172 |
+index 1e60d67..b4e871b 100644 |
173 |
+--- a/burrow-exporter.go |
174 |
++++ b/burrow-exporter.go |
175 |
+@@ -14,7 +14,7 @@ import ( |
176 |
+ "github.com/jirwin/burrow_exporter/burrow_exporter" |
177 |
+ ) |
178 |
+ |
179 |
+-var Version = "0.0.4" |
180 |
++var Version = "0.0.5" |
181 |
+ |
182 |
+ func main() { |
183 |
+ app := cli.NewApp() |
184 |
+@@ -22,36 +22,61 @@ func main() { |
185 |
+ app.Name = "burrow-exporter" |
186 |
+ app.Flags = []cli.Flag{ |
187 |
+ cli.StringFlag{ |
188 |
+- Name: "burrow-addr", |
189 |
+- Usage: "Address that burrow is listening on", |
190 |
++ Name: "burrow-addr", |
191 |
++ Usage: "Address that burrow is listening on", |
192 |
+ EnvVar: "BURROW_ADDR", |
193 |
+ }, |
194 |
+ cli.StringFlag{ |
195 |
+- Name: "metrics-addr", |
196 |
+- Usage: "Address to run prometheus on", |
197 |
++ Name: "metrics-addr", |
198 |
++ Usage: "Address to run prometheus on", |
199 |
+ EnvVar: "METRICS_ADDR", |
200 |
+ }, |
201 |
+ cli.IntFlag{ |
202 |
+- Name: "interval", |
203 |
+- Usage: "The interval(seconds) specifies how often to scrape burrow.", |
204 |
++ Name: "interval", |
205 |
++ Usage: "The interval(seconds) specifies how often to scrape burrow.", |
206 |
+ EnvVar: "INTERVAL", |
207 |
+ }, |
208 |
+ cli.IntFlag{ |
209 |
+- Name: "api-version", |
210 |
+- Usage: "Burrow API version to leverage", |
211 |
+- Value: 2, |
212 |
++ Name: "api-version", |
213 |
++ Usage: "Burrow API version to leverage", |
214 |
++ Value: 2, |
215 |
+ EnvVar: "API_VERSION", |
216 |
+ }, |
217 |
+ cli.BoolFlag{ |
218 |
+- Name: "skip-partition-status", |
219 |
+- Usage: "Skip exporting the per-partition status", |
220 |
++ Name: "skip-partition-status", |
221 |
++ Usage: "Skip exporting the per-partition status", |
222 |
+ EnvVar: "SKIP_PARTITION_STATUS", |
223 |
+ }, |
224 |
+ cli.BoolFlag{ |
225 |
+- Name: "skip-group-status", |
226 |
+- Usage: "Skip exporting the per-group status", |
227 |
++ Name: "skip-group-status", |
228 |
++ Usage: "Skip exporting the per-group status", |
229 |
+ EnvVar: "SKIP_GROUP_STATUS", |
230 |
+ }, |
231 |
++ cli.BoolFlag{ |
232 |
++ Name: "skip-partition-lag", |
233 |
++ Usage: "Skip exporting the partition lag", |
234 |
++ EnvVar: "SKIP_PARTITION_LAG", |
235 |
++ }, |
236 |
++ cli.BoolFlag{ |
237 |
++ Name: "skip-partition-current-offset", |
238 |
++ Usage: "Skip exporting the current offset per partition", |
239 |
++ EnvVar: "SKIP_PARTITION_CURRENT_OFFSET", |
240 |
++ }, |
241 |
++ cli.BoolFlag{ |
242 |
++ Name: "skip-partition-max-offset", |
243 |
++ Usage: "Skip exporting the partition max offset", |
244 |
++ EnvVar: "SKIP_PARTITION_MAX_OFFSET", |
245 |
++ }, |
246 |
++ cli.BoolFlag{ |
247 |
++ Name: "skip-total-lag", |
248 |
++ Usage: "Skip exporting the total lag", |
249 |
++ EnvVar: "SKIP_TOTAL_LAG", |
250 |
++ }, |
251 |
++ cli.BoolFlag{ |
252 |
++ Name: "skip-topic-partition-offset", |
253 |
++ Usage: "Skip exporting topic partition offset", |
254 |
++ EnvVar: "SKIP_TOPIC_PARTITION_OFFSET", |
255 |
++ }, |
256 |
+ } |
257 |
+ |
258 |
+ app.Action = func(c *cli.Context) error { |
259 |
+@@ -76,8 +101,18 @@ func main() { |
260 |
+ |
261 |
+ ctx, cancel := context.WithCancel(context.Background()) |
262 |
+ |
263 |
+- exporter := burrow_exporter.MakeBurrowExporter(c.String("burrow-addr"), c.Int("api-version"), |
264 |
+- c.String("metrics-addr"), c.Int("interval"), c.Bool("skip-partition-status"), c.Bool("skip-group-status")) |
265 |
++ exporter := burrow_exporter.MakeBurrowExporter( |
266 |
++ c.String("burrow-addr"), |
267 |
++ c.Int("api-version"), |
268 |
++ c.String("metrics-addr"), |
269 |
++ c.Int("interval"), |
270 |
++ c.Bool("skip-partition-status"), |
271 |
++ c.Bool("skip-group-status"), |
272 |
++ c.Bool("skip-partition-lag"), |
273 |
++ c.Bool("skip-partition-current-offset"), |
274 |
++ c.Bool("skip-partition-max-offset"), |
275 |
++ c.Bool("skip-total-lag"), |
276 |
++ c.Bool("skip-topic-partition-offset")) |
277 |
+ go exporter.Start(ctx) |
278 |
+ |
279 |
+ <-done |
280 |
+diff --git a/burrow_exporter/exporter.go b/burrow_exporter/exporter.go |
281 |
+index 7adc398..8b48b35 100644 |
282 |
+--- a/burrow_exporter/exporter.go |
283 |
++++ b/burrow_exporter/exporter.go |
284 |
+@@ -16,12 +16,17 @@ import ( |
285 |
+ ) |
286 |
+ |
287 |
+ type BurrowExporter struct { |
288 |
+- client *BurrowClient |
289 |
+- metricsListenAddr string |
290 |
+- interval int |
291 |
+- wg sync.WaitGroup |
292 |
+- skipPartitionStatus bool |
293 |
+- skipConsumerStatus bool |
294 |
++ client *BurrowClient |
295 |
++ metricsListenAddr string |
296 |
++ interval int |
297 |
++ wg sync.WaitGroup |
298 |
++ skipPartitionStatus bool |
299 |
++ skipConsumerStatus bool |
300 |
++ skipPartitionLag bool |
301 |
++ skipPartitionCurrentOffset bool |
302 |
++ skipPartitionMaxOffset bool |
303 |
++ skipTotalLag bool |
304 |
++ skipTopicPartitionOffset bool |
305 |
+ } |
306 |
+ |
307 |
+ func (be *BurrowExporter) processGroup(cluster, group string) { |
308 |
+@@ -34,19 +39,23 @@ func (be *BurrowExporter) processGroup(cluster, group string) { |
309 |
+ } |
310 |
+ |
311 |
+ for _, partition := range status.Status.Partitions { |
312 |
+- KafkaConsumerPartitionLag.With(prometheus.Labels{ |
313 |
+- "cluster": status.Status.Cluster, |
314 |
+- "group": status.Status.Group, |
315 |
+- "topic": partition.Topic, |
316 |
+- "partition": strconv.Itoa(int(partition.Partition)), |
317 |
+- }).Set(float64(partition.End.Lag)) |
318 |
+- |
319 |
+- KafkaConsumerPartitionCurrentOffset.With(prometheus.Labels{ |
320 |
+- "cluster": status.Status.Cluster, |
321 |
+- "group": status.Status.Group, |
322 |
+- "topic": partition.Topic, |
323 |
+- "partition": strconv.Itoa(int(partition.Partition)), |
324 |
+- }).Set(float64(partition.End.Offset)) |
325 |
++ if !be.skipPartitionLag { |
326 |
++ KafkaConsumerPartitionLag.With(prometheus.Labels{ |
327 |
++ "cluster": status.Status.Cluster, |
328 |
++ "group": status.Status.Group, |
329 |
++ "topic": partition.Topic, |
330 |
++ "partition": strconv.Itoa(int(partition.Partition)), |
331 |
++ }).Set(float64(partition.End.Lag)) |
332 |
++ } |
333 |
++ |
334 |
++ if !be.skipPartitionCurrentOffset { |
335 |
++ KafkaConsumerPartitionCurrentOffset.With(prometheus.Labels{ |
336 |
++ "cluster": status.Status.Cluster, |
337 |
++ "group": status.Status.Group, |
338 |
++ "topic": partition.Topic, |
339 |
++ "partition": strconv.Itoa(int(partition.Partition)), |
340 |
++ }).Set(float64(partition.End.Offset)) |
341 |
++ } |
342 |
+ |
343 |
+ if !be.skipPartitionStatus { |
344 |
+ KafkaConsumerPartitionCurrentStatus.With(prometheus.Labels{ |
345 |
+@@ -57,18 +66,22 @@ func (be *BurrowExporter) processGroup(cluster, group string) { |
346 |
+ }).Set(float64(Status[partition.Status])) |
347 |
+ } |
348 |
+ |
349 |
+- KafkaConsumerPartitionMaxOffset.With(prometheus.Labels{ |
350 |
+- "cluster": status.Status.Cluster, |
351 |
+- "group": status.Status.Group, |
352 |
+- "topic": partition.Topic, |
353 |
+- "partition": strconv.Itoa(int(partition.Partition)), |
354 |
+- }).Set(float64(partition.End.MaxOffset)) |
355 |
++ if !be.skipPartitionMaxOffset { |
356 |
++ KafkaConsumerPartitionMaxOffset.With(prometheus.Labels{ |
357 |
++ "cluster": status.Status.Cluster, |
358 |
++ "group": status.Status.Group, |
359 |
++ "topic": partition.Topic, |
360 |
++ "partition": strconv.Itoa(int(partition.Partition)), |
361 |
++ }).Set(float64(partition.End.MaxOffset)) |
362 |
++ } |
363 |
+ } |
364 |
+ |
365 |
+- KafkaConsumerTotalLag.With(prometheus.Labels{ |
366 |
+- "cluster": status.Status.Cluster, |
367 |
+- "group": status.Status.Group, |
368 |
+- }).Set(float64(status.Status.TotalLag)) |
369 |
++ if !be.skipTotalLag { |
370 |
++ KafkaConsumerTotalLag.With(prometheus.Labels{ |
371 |
++ "cluster": status.Status.Cluster, |
372 |
++ "group": status.Status.Group, |
373 |
++ }).Set(float64(status.Status.TotalLag)) |
374 |
++ } |
375 |
+ |
376 |
+ if !be.skipConsumerStatus { |
377 |
+ KafkaConsumerStatus.With(prometheus.Labels{ |
378 |
+@@ -88,12 +101,14 @@ func (be *BurrowExporter) processTopic(cluster, topic string) { |
379 |
+ return |
380 |
+ } |
381 |
+ |
382 |
+- for i, offset := range details.Offsets { |
383 |
+- KafkaTopicPartitionOffset.With(prometheus.Labels{ |
384 |
+- "cluster": cluster, |
385 |
+- "topic": topic, |
386 |
+- "partition": strconv.Itoa(i), |
387 |
+- }).Set(float64(offset)) |
388 |
++ if !be.skipTopicPartitionOffset { |
389 |
++ for i, offset := range details.Offsets { |
390 |
++ KafkaTopicPartitionOffset.With(prometheus.Labels{ |
391 |
++ "cluster": cluster, |
392 |
++ "topic": topic, |
393 |
++ "partition": strconv.Itoa(i), |
394 |
++ }).Set(float64(offset)) |
395 |
++ } |
396 |
+ } |
397 |
+ } |
398 |
+ |
399 |
+@@ -208,12 +223,17 @@ func (be *BurrowExporter) mainLoop(ctx context.Context) { |
400 |
+ } |
401 |
+ |
402 |
+ func MakeBurrowExporter(burrowUrl string, apiVersion int, metricsAddr string, interval int, skipPartitionStatus bool, |
403 |
+- skipConsumerStatus bool) *BurrowExporter { |
404 |
++ skipConsumerStatus bool, skipPartitionLag bool, skipPartitionCurrentOffset bool, skipPartitionMaxOffset bool, skipTotalLag bool, skipTopicPartitionOffset bool) *BurrowExporter { |
405 |
+ return &BurrowExporter{ |
406 |
+- client: MakeBurrowClient(burrowUrl, apiVersion), |
407 |
+- metricsListenAddr: metricsAddr, |
408 |
+- interval: interval, |
409 |
+- skipPartitionStatus: skipPartitionStatus, |
410 |
+- skipConsumerStatus: skipConsumerStatus, |
411 |
++ client: MakeBurrowClient(burrowUrl, apiVersion), |
412 |
++ metricsListenAddr: metricsAddr, |
413 |
++ interval: interval, |
414 |
++ skipPartitionStatus: skipPartitionStatus, |
415 |
++ skipConsumerStatus: skipConsumerStatus, |
416 |
++ skipPartitionLag: skipPartitionLag, |
417 |
++ skipPartitionCurrentOffset: skipPartitionCurrentOffset, |
418 |
++ skipPartitionMaxOffset: skipPartitionMaxOffset, |
419 |
++ skipTotalLag: skipTotalLag, |
420 |
++ skipTopicPartitionOffset: skipTopicPartitionOffset, |
421 |
+ } |
422 |
+ } |
423 |
|
424 |
diff --git a/app-metrics/burrow_exporter/files/burrow_exporter.logrotated b/app-metrics/burrow_exporter/files/burrow_exporter.logrotated |
425 |
new file mode 100644 |
426 |
index 00000000000..de78d102c0f |
427 |
--- /dev/null |
428 |
+++ b/app-metrics/burrow_exporter/files/burrow_exporter.logrotated |
429 |
@@ -0,0 +1,7 @@ |
430 |
+/var/log/burrow_exporter/burrow_exporter.log { |
431 |
+ missingok |
432 |
+ size 5M |
433 |
+ rotate 3 |
434 |
+ compress |
435 |
+ copytruncate |
436 |
+} |