From 56dd13981c1567bd12cc0921b3e38be553428a2b Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 2 Apr 2025 22:27:49 +0800 Subject: [PATCH] Create a docker-compose-obs.yaml file related to observability --- .docker/observability/conifg/obs.toml | 33 ++++++ Dockerfile.obs | 19 ++++ data/README.md | 0 docker-compose-obs.yaml | 148 ++++++++++++++++++++++++++ 4 files changed, 200 insertions(+) create mode 100644 .docker/observability/conifg/obs.toml create mode 100644 Dockerfile.obs create mode 100644 data/README.md create mode 100644 docker-compose-obs.yaml diff --git a/.docker/observability/conifg/obs.toml b/.docker/observability/conifg/obs.toml new file mode 100644 index 000000000..2454934f6 --- /dev/null +++ b/.docker/observability/conifg/obs.toml @@ -0,0 +1,33 @@ +[observability] +endpoint = "http://localhost:4317" # Default is "http://localhost:4317" if not specified +use_stdout = true +sample_ratio = 2.0 +meter_interval = 30 +service_name = "rustfs" +service_version = "0.1.0" +environments = "develop" +logger_levela = "info" + +[sinks] +[sinks.kafka] # Kafka sink is disabled by default +enabled = false +bootstrap_servers = "localhost:9092" +topic = "logs" +batch_size = 100 # Default is 100 if not specified +batch_timeout_ms = 1000 # Default is 1000ms if not specified + +[sinks.webhook] +enabled = false +endpoint = "http://localhost:8080/webhook" +auth_token = "" +batch_size = 100 # Default is 3 if not specified +batch_timeout_ms = 1000 # Default is 100ms if not specified + +[sinks.file] +enabled = true +path = "/Users/qun/Documents/rust/rustfs/s3-rustfs/logs/app.log" +batch_size = 10 +batch_timeout_ms = 1000 # Default is 8192 bytes if not specified + +[logger] +queue_capacity = 10 \ No newline at end of file diff --git a/Dockerfile.obs b/Dockerfile.obs new file mode 100644 index 000000000..5a6148ab0 --- /dev/null +++ b/Dockerfile.obs @@ -0,0 +1,19 @@ +FROM alpine:latest + +# RUN apk add --no-cache +# 如果 rustfs 有依赖,可以在这里添加,例如: +# RUN apk add --no-cache openssl + +WORKDIR /app + +# 创建与 RUSTFS_VOLUMES 一致的目录 +RUN mkdir -p /root/data/target/volume/test1 /root/data/target/volume/test2 /root/data/target/volume/test3 /root/data/target/volume/test4 + +COPY ./target/x86_64-unknown-linux-musl/release/rustfs /app/rustfs + +RUN chmod +x /app/rustfs + +EXPOSE 9000 +EXPOSE 9002 + +CMD ["/app/rustfs"] \ No newline at end of file diff --git a/data/README.md b/data/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/docker-compose-obs.yaml b/docker-compose-obs.yaml new file mode 100644 index 000000000..4630106e3 --- /dev/null +++ b/docker-compose-obs.yaml @@ -0,0 +1,148 @@ +services: + otel-collector: + image: otel/opentelemetry-collector-contrib:0.120.0 + environment: + - TZ=Asia/Shanghai + volumes: + - ./.docker/observability/otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml + ports: + - 1888:1888 + - 8888:8888 + - 8889:8889 + - 13133:13133 + - 4317:4317 + - 4318:4318 + - 55679:55679 + networks: + - rustfs-network + jaeger: + image: jaegertracing/jaeger:2.4.0 + environment: + - TZ=Asia/Shanghai + ports: + - "16686:16686" + - "14317:4317" + - "14318:4318" + networks: + - rustfs-network + prometheus: + image: prom/prometheus:v3.2.1 + environment: + - TZ=Asia/Shanghai + volumes: + - ./.docker/observability/prometheus.yml:/etc/prometheus/prometheus.yml + ports: + - "9090:9090" + networks: + - rustfs-network + loki: + image: grafana/loki:3.4.2 + environment: + - TZ=Asia/Shanghai + volumes: + - ./.docker/observability/loki-config.yaml:/etc/loki/local-config.yaml + ports: + - "3100:3100" + command: -config.file=/etc/loki/local-config.yaml + networks: + - rustfs-network + grafana: + image: grafana/grafana:11.6.0 + ports: + - "3000:3000" # Web UI + environment: + - GF_SECURITY_ADMIN_PASSWORD=admin + - TZ=Asia/Shanghai + networks: + - rustfs-network + + node1: + build: + context: . + dockerfile: Dockerfile.obs + container_name: node1 + environment: + - RUSTFS_VOLUMES=http://node{1...4}:9000/root/data/target/volume/test{1...4} + - RUSTFS_ADDRESS=0.0.0.0:9000 + - RUSTFS_CONSOLE_ENABLE=true + - RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002 + - RUSTFS_OBS_CONFIG=/etc/observability/config.obs.toml + platform: linux/amd64 + ports: + - "9001:9000" # 映射宿主机的 9001 端口到容器的 9000 端口 + - "9101:9002" + volumes: + - ./data:/root/data # 将当前路径挂载到容器内的 /root/data + - ./.docker/observability/config/obs.toml:/etc/observability/config.obs.toml + networks: + - rustfs-network + + node2: + build: + context: . + dockerfile: Dockerfile.obs + container_name: node2 + environment: + - RUSTFS_VOLUMES=http://node{1...4}:9000/root/data/target/volume/test{1...4} + - RUSTFS_ADDRESS=0.0.0.0:9000 + - RUSTFS_CONSOLE_ENABLE=true + - RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002 + - RUSTFS_OBS_CONFIG=/etc/observability/config.obs.toml + platform: linux/amd64 + ports: + - "9002:9000" # 映射宿主机的 9002 端口到容器的 9000 端口 + - "9102:9002" + volumes: + - ./data:/root/data + - ./.docker/observability/config/obs.toml:/etc/observability/config.obs.toml + networks: + - rustfs-network + + node3: + build: + context: . + dockerfile: Dockerfile.obs + container_name: node3 + environment: + - RUSTFS_VOLUMES=http://node{1...4}:9000/root/data/target/volume/test{1...4} + - RUSTFS_ADDRESS=0.0.0.0:9000 + - RUSTFS_CONSOLE_ENABLE=true + - RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002 + - RUSTFS_OBS_CONFIG=/etc/observability/config.obs.toml + platform: linux/amd64 + ports: + - "9003:9000" # 映射宿主机的 9003 端口到容器的 9000 端口 + - "9103:9002" + volumes: + - ./data:/root/data + - ./.docker/observability/config/obs.toml:/etc/observability/config.obs.toml + networks: + - rustfs-network + + node4: + build: + context: . + dockerfile: Dockerfile.obs + container_name: node4 + environment: + - RUSTFS_VOLUMES=http://node{1...4}:9000/root/data/target/volume/test{1...4} + - RUSTFS_ADDRESS=0.0.0.0:9000 + - RUSTFS_CONSOLE_ENABLE=true + - RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002 + - RUSTFS_OBS_CONFIG=/etc/observability/config.obs.toml + platform: linux/amd64 + ports: + - "9004:9000" # 映射宿主机的 9004 端口到容器的 9000 端口 + - "9104:9002" + volumes: + - ./data:/root/data + - ./.docker/observability/config/obs.toml:/etc/observability/config.obs.toml + networks: + - rustfs-network + +networks: + rustfs-network: + driver: bridge + name: "network_otel_config" + driver_opts: + com.docker.network.enable_ipv6: "true"