Skip to content

Commit 06198bb

Browse files
committed
improve collector docs
1 parent 2fa11ae commit 06198bb

File tree

2 files changed

+139
-55
lines changed

2 files changed

+139
-55
lines changed

README.md

Lines changed: 137 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -177,59 +177,7 @@ metrics:
177177
> endpoints of the services being benchmarked by exposing the necessary ports
178178
> in the Docker Compose configurations.
179179

180-
Available collectors and their configurations:
181-
182-
- `conduit`: Conduit metrics collector. Tracks messages per second for each
183-
pipeline.
184-
- `url`: URL of the Conduit metrics endpoint.
185-
186-
```yaml
187-
metrics:
188-
my-conduit-collector:
189-
collector: "conduit"
190-
settings:
191-
url: "http://localhost:8080/metrics"
192-
```
193-
194-
- `kafka`: Kafka metrics collector. Tracks messages per second and bytes per
195-
second for each configured topic.
196-
- `url`: URL of the Kafka metrics endpoint.
197-
- `topics`: Array of topics to track.
198-
199-
```yaml
200-
metrics:
201-
my-kafka-collector:
202-
collector: "kafka"
203-
settings:
204-
url: "http://localhost:7071/metrics"
205-
topics:
206-
- "topic1"
207-
- "topic2"
208-
```
209-
210-
- `prometheus`: Prometheus metrics collector. Queries Prometheus for metrics.
211-
- `url`: URL of the Prometheus metrics endpoint.
212-
- `queries`: Array of queries to run.
213-
- `name`: Name of the query.
214-
- `query`: Prometheus query.
215-
- `unit`: Unit of the query.
216-
- `interval`: Interval at which to run the query.
217-
218-
```yaml
219-
metrics:
220-
my-prometheus-collector:
221-
collector: "prometheus"
222-
settings:
223-
url: "http://localhost:8080/metrics"
224-
queries:
225-
- name: "http_request_success_rate"
226-
query: "rate(request_count{endpoint=hello,status=200}[2s])"
227-
unit: "req/s"
228-
interval: "1s"
229-
- name: "http_request_fail_rate"
230-
query: "rate(request_count{endpoint=hello,status!=200}[2s])"
231-
interval: "1s"
232-
```
180+
See [collectors](#collectors) for available collectors and their configurations.
233181

234182
#### `tests`
235183

@@ -336,6 +284,142 @@ tests:
336284
compose: "./compose-file-tool.override.yml"
337285
```
338286

287+
## Collectors
288+
289+
Collectors are used to collect metrics from various sources during the benchmark
290+
run. The collected metrics are exported in CSV format for further analysis.
291+
292+
Collectors are configured in the [`metrics` section](#metrics) of the benchmark
293+
configuration file.
294+
295+
Supported collectors:
296+
297+
- [Conduit](#conduit)
298+
- [Docker](#docker)
299+
- [Kafka](#kafka)
300+
- [Prometheus](#prometheus)
301+
302+
### Conduit
303+
304+
The Conduit metrics collector tracks the throughput for each configured
305+
pipeline in [Conduit](https://github.com/conduitio/conduit).
306+
307+
Settings:
308+
309+
- `url`: URL of the Conduit metrics endpoint (needs to be reachable from the
310+
benchi process).
311+
- `pipelines`: Array of pipelines to track.
312+
313+
```yaml
314+
metrics:
315+
my-conduit-collector:
316+
collector: "conduit"
317+
settings:
318+
url: "http://localhost:8080/metrics"
319+
pipelines:
320+
- "pipeline1"
321+
- "pipeline2"
322+
```
323+
324+
Metrics:
325+
326+
- `msg-rate-per-second[PIPELINE]`: Messages per second per pipeline.
327+
- `msg-megabytes-in-per-second[PIPELINE]`: Incoming megabytes per second per
328+
pipeline (measured as records read by the source connector).
329+
- `msg-megabytes-out-per-second[PIPELINE]`: Outgoing megabytes per second per
330+
pipeline (measured as records written by the destination connector).
331+
332+
### Docker
333+
334+
The Docker metrics collector tracks the container resource usage during the
335+
benchmark run.
336+
337+
Settings:
338+
339+
- `containers`: Array of containers to track.
340+
341+
```yaml
342+
metrics:
343+
my-docker-collector:
344+
collector: "docker"
345+
settings:
346+
containers:
347+
- "my-app"
348+
- "database"
349+
- "cache"
350+
```
351+
352+
Metrics:
353+
354+
- `cpu-percentage[CONTAINER]`: CPU usage in percent at a specific point in time
355+
per container.
356+
- `memory-usage[CONTAINER]`: Memory usage in megabytes at a specific point in
357+
time per container.
358+
359+
### Kafka
360+
361+
The Kafka metrics collector tracks the throughput for each configured topic in
362+
[Apache Kafka](https://kafka.apache.org/).
363+
364+
The collector expects Kafka to expose a Prometheus metrics endpoint via the
365+
[Prometheus JMX exporter](https://prometheus.github.io/jmx_exporter/). To see
366+
how to configure it, check out the
367+
[example configuration](./example/infra/compose-kafka.yml).
368+
369+
Settings:
370+
371+
- `url`: URL of the Kafka metrics endpoint (needs to be reachable from the
372+
benchi process).
373+
- `topics`: Array of topics to track.
374+
375+
```yaml
376+
metrics:
377+
my-kafka-collector:
378+
collector: "kafka"
379+
settings:
380+
url: "http://localhost:7071/metrics"
381+
topics:
382+
- "topic1"
383+
- "topic2"
384+
```
385+
386+
### Prometheus
387+
388+
The Prometheus metrics collector continuously scrapes a metrics endpoint, stores
389+
the metrics in memory and queries them using
390+
[PromQL](https://prometheus.io/docs/prometheus/latest/querying/basics/).
391+
392+
It is expected that the query returns a matrix with a single series. The query
393+
should be a
394+
[ranged query](https://prometheus.io/docs/prometheus/latest/querying/basics/#range-vector-selectors),
395+
which will be evaluated between the start of the test and the end of the test.
396+
397+
Settings:
398+
399+
- `url`: URL of the Prometheus metrics endpoint.
400+
- `queries`: Array of queries to run.
401+
- `name`: Name of the query.
402+
- `query`: [PromQL](https://prometheus.io/docs/prometheus/latest/querying/basics/) query.
403+
- `unit`: Unit of the query (optional, only for displaying in the CLI).
404+
- `interval`: Resolution of the ranged query.
405+
406+
```yaml
407+
metrics:
408+
my-prometheus-collector:
409+
collector: "prometheus"
410+
settings:
411+
url: "http://localhost:8080/metrics"
412+
queries:
413+
- name: "http_request_success_rate"
414+
query: "rate(request_count{endpoint=hello,status=200}[2s])"
415+
unit: "req/s"
416+
interval: "1s"
417+
- name: "http_request_fail_rate"
418+
query: "rate(request_count{endpoint=hello,status!=200}[2s])"
419+
unit: "req/s"
420+
interval: "1s"
421+
```
422+
339423
## Troubleshooting
340424

341425
- Benchi fails with the error `Cannot connect to the Docker daemon at

metrics/docker/collector.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ type sampleCollector struct {
158158
var sampleCollectors = []sampleCollector{
159159
{
160160
name: func(container string) string {
161-
return fmt.Sprintf("cpu_percentage[%s]", container)
161+
return fmt.Sprintf("cpu-percentage[%s]", container)
162162
},
163163
unit: "%",
164164
sample: func(entry statsEntry) metrics.Sample {
@@ -167,7 +167,7 @@ var sampleCollectors = []sampleCollector{
167167
},
168168
{
169169
name: func(container string) string {
170-
return fmt.Sprintf("memory_usage[%s]", container)
170+
return fmt.Sprintf("memory-usage[%s]", container)
171171
},
172172
unit: "MB",
173173
sample: func(entry statsEntry) metrics.Sample {

0 commit comments

Comments
 (0)