Skip to content

Commit

Permalink
ci(ch-log-bench-read): add LogQL benchmark setup
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Jun 20, 2024
1 parent a8580d9 commit 7122c98
Show file tree
Hide file tree
Showing 9 changed files with 254 additions and 0 deletions.
1 change: 1 addition & 0 deletions dev/local/ch-log-bench-read/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
record
3 changes: 3 additions & 0 deletions dev/local/ch-log-bench-read/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
record
/report.yml
/req.rwq
26 changes: 26 additions & 0 deletions dev/local/ch-log-bench-read/clickhouse.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<clickhouse>
<listen_host>0.0.0.0</listen_host>
<logger>
<level>information</level>
<console>true</console>
<log remove="remove"/>
<errorlog remove="remove"/>
</logger>
<prometheus>
<endpoint>/metrics</endpoint>
<port>8080</port>
<metrics>true</metrics>
<events>true</events>
<asynchronous_metrics>true</asynchronous_metrics>
</prometheus>
<opentelemetry_span_log>
<engine>
engine MergeTree
order by (start_time_us, trace_id)
ttl toDateTime(finish_time_us/1000000) + toIntervalMinute(15)
</engine>
<database>system</database>
<table>opentelemetry_span_log</table>
<flush_interval_milliseconds>10</flush_interval_milliseconds>
</opentelemetry_span_log>
</clickhouse>
86 changes: 86 additions & 0 deletions dev/local/ch-log-bench-read/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
version: "3"

services:
clickhouse:
image: "ghcr.io/go-faster/clickhouse-server:23.12"
ports:
- "127.0.0.1:9000:9000"
- "127.0.0.1:8123:8123"
volumes:
- ./clickhouse.xml:/etc/clickhouse-server/config.d/monitoring.xml:ro
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "127.0.0.1:8123/ping"]
interval: 1s
timeout: 1s
retries: 30

oteldb:
image: ghcr.io/go-faster/oteldb
build:
context: ../../../
dockerfile: Dockerfile
command:
- --config=/etc/otel/cfg.yml
volumes:
- ./oteldb.yml:/etc/otel/cfg.yml:ro
environment:
- PPROF_ADDR=0.0.0.0:9010
- OTELDB_STORAGE=ch
- OTEL_LOG_LEVEL=info
- OTEL_EXPORTER_PROMETHEUS_HOST=0.0.0.0
- OTEL_EXPORTER_PROMETHEUS_PORT=9464
- OTEL_METRICS_EXPORTER=prometheus
- OTEL_LOGS_EXPORTER=none
- OTEL_TRACES_EXPORTER=otlp
- OTEL_TRACES_SAMPLER=parentbased_always_off
- OTEL_EXPORTER_OTLP_PROTOCOL=grpc
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otelcol:4317
- OTEL_RESOURCE_ATTRIBUTES=service.name=go-faster.oteldb
- GOMAXPROCS=6
- GOMEMLIMIT=1500MiB
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "127.0.0.1:13133/liveness"]
interval: 1s
timeout: 1s
retries: 30
ports:
- "127.0.0.1:3100:3100" # logql
- "127.0.0.1:4318:4317" # OpenTelemetry receiver
- "127.0.0.1:9010:9010" # pprof
depends_on:
- clickhouse

# Exports traces from clickhouse internal table to otel.
chotel:
image: ghcr.io/go-faster/oteldb/chotel
build:
context: ../../../
dockerfile: chotel.Dockerfile
restart: always
environment:
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otelcol:4317
- OTEL_EXPORTER_OTLP_PROTOCOL=grpc
- OTEL_EXPORTER_OTLP_INSECURE=true
- OTEL_RESOURCE_ATTRIBUTES=service.name=go-faster.oteldb.chotel
- CHOTEL_SEND_RATE=1s
depends_on:
- clickhouse

tempo:
image: "ghcr.io/go-faster/tempo"
command: ["-config.file=/etc/tempo.yml"]
ports:
- "127.0.0.1:3200:3200"
volumes:
- ./tempo.yml:/etc/tempo.yml:ro

# https://opentelemetry.io/docs/collector/installation/#docker-compose
otelcol:
image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.89.0
volumes:
- ./otelcol.yml:/etc/otelcol-contrib/config.yaml:ro
ports:
- "127.0.0.1:4317:4317"
command:
- "--config"
- "/etc/otelcol-contrib/config.yaml"
21 changes: 21 additions & 0 deletions dev/local/ch-log-bench-read/otelcol.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
receivers:
otlp:
protocols:
grpc:

exporters:
otlp:
endpoint: tempo:4317
tls:
insecure: true

extensions:
health_check:
pprof:
zpages:

service:
pipelines:
traces:
receivers: [otlp]
exporters: [otlp]
21 changes: 21 additions & 0 deletions dev/local/ch-log-bench-read/oteldb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
dsn: clickhouse://clickhouse:9000
loki:
bind: 0.0.0.0:3100
health_check:
bind: 0.0.0.0:13133
otelcol:
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
exporters:
oteldbexporter:
dsn: clickhouse://clickhouse:9000
service:
pipelines:
logs:
receivers: [otlp]
exporters: [oteldbexporter]
42 changes: 42 additions & 0 deletions dev/local/ch-log-bench-read/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

clean_up() {
ARG=$?
echo ">> Stopping"
docker compose down -v
exit $ARG
}
trap clean_up EXIT

set -e

echo ">> Setup oteldb locally"
docker compose up -d --remove-orphans --build --force-recreate

start_time="2024-01-01T00:01:10Z"
end_time="2024-01-01T00:05:10Z"

echo ">> Generate benchmark data"
go run github.com/go-faster/oteldb/cmd/otelbench otel logs bench \
localhost:4318 \
--start "$start_time" \
--rate 1ms \
--entries 150 \
--clickhouseAddr "localhost:9000" \
--total 100000

echo ">> Benchmark"
queries_file="${BENCH_QUERIES:-testdata/logql.yml}"
benchmark_runs="${BENCH_RUNS:-15}"

OTEL_EXPORTER_OTLP_INSECURE="true" go run github.com/go-faster/oteldb/cmd/otelbench logql bench \
--start "$start_time" \
--end "$end_time" \
-i "$queries_file" \
-o report.yml \
--trace \
--allow-empty=false \
--count "$benchmark_runs" \
--warmup 5

echo ">> Done"
47 changes: 47 additions & 0 deletions dev/local/ch-log-bench-read/tempo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
server:
http_listen_port: 3200

query_frontend:
search:
duration_slo: 5s
throughput_bytes_slo: 1.073741824e+09
trace_by_id:
duration_slo: 5s

distributor:
receivers:
otlp:
protocols:
http:
grpc:

ingester:
max_block_duration: 5m # cut the headblock when this much time passes. this is being set for demo purposes and should probably be left alone normally

compactor:
compaction:
block_retention: 1h # overall Tempo trace retention. set for demo purposes

metrics_generator:
registry:
external_labels:
source: tempo
cluster: docker-compose
storage:
path: /tmp/tempo/generator/wal
remote_write:
- url: http://prometheus:9090/api/v1/write
send_exemplars: true

storage:
trace:
backend: local # backend configuration to use
wal:
path: /tmp/tempo/wal # where to store the the wal locally
local:
path: /tmp/tempo/blocks

overrides:
defaults:
metrics_generator:
processors: [service-graphs, span-metrics] # enables metrics generator
7 changes: 7 additions & 0 deletions dev/local/ch-log-bench-read/testdata/logql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
range:
- title: Failed POST requests
query: |-
{http_method="POST"} |= "Error"
series:
- title: All POST series
match: ['{http_method="POST"}']

0 comments on commit 7122c98

Please sign in to comment.