Created
January 21, 2026 15:52
-
-
Save tedmax100/a588754e12e6e5cc0788a8df67337fd5 to your computer and use it in GitHub Desktop.
deltatocumulative
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| services: | |
| # OTel Collector Contrib (核心角色) | |
| otel-collector: | |
| image: otel/opentelemetry-collector-contrib:0.142.0 | |
| command: ["--config=/etc/otel-collector-config.yaml"] | |
| volumes: | |
| - ./otel-config.yaml:/etc/otel-collector-config.yaml:ro | |
| ports: | |
| - "4317:4317" | |
| - "8888:8888" | |
| - "8889:8889" | |
| networks: | |
| - otel-network | |
| # Prometheus (驗證與監控) | |
| prometheus: | |
| image: prom/prometheus:latest | |
| volumes: | |
| - ./prometheus.yaml:/etc/prometheus/prometheus.yml:ro | |
| ports: | |
| - "9090:9090" | |
| depends_on: | |
| - otel-collector | |
| networks: | |
| - otel-network | |
| # 流量產生器 - 60 個實例 (超過 max_streams=50) | |
| # 使用 x-telemetrygen 作為 YAML anchor | |
| telemetrygen-01: &telemetrygen-base | |
| image: ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:latest | |
| command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-01"] | |
| depends_on: [otel-collector] | |
| networks: [otel-network] | |
| telemetrygen-02: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-02"] } | |
| telemetrygen-03: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-03"] } | |
| telemetrygen-04: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-04"] } | |
| telemetrygen-05: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-05"] } | |
| telemetrygen-06: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-06"] } | |
| telemetrygen-07: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-07"] } | |
| telemetrygen-08: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-08"] } | |
| telemetrygen-09: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-09"] } | |
| telemetrygen-10: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-10"] } | |
| telemetrygen-11: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-11"] } | |
| telemetrygen-12: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-12"] } | |
| telemetrygen-13: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-13"] } | |
| telemetrygen-14: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-14"] } | |
| telemetrygen-15: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-15"] } | |
| telemetrygen-16: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-16"] } | |
| telemetrygen-17: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-17"] } | |
| telemetrygen-18: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-18"] } | |
| telemetrygen-19: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-19"] } | |
| telemetrygen-20: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-20"] } | |
| telemetrygen-21: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-21"] } | |
| telemetrygen-22: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-22"] } | |
| telemetrygen-23: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-23"] } | |
| telemetrygen-24: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-24"] } | |
| telemetrygen-25: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-25"] } | |
| telemetrygen-26: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-26"] } | |
| telemetrygen-27: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-27"] } | |
| telemetrygen-28: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-28"] } | |
| telemetrygen-29: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-29"] } | |
| telemetrygen-30: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-30"] } | |
| telemetrygen-31: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-31"] } | |
| telemetrygen-32: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-32"] } | |
| telemetrygen-33: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-33"] } | |
| telemetrygen-34: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-34"] } | |
| telemetrygen-35: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-35"] } | |
| telemetrygen-36: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-36"] } | |
| telemetrygen-37: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-37"] } | |
| telemetrygen-38: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-38"] } | |
| telemetrygen-39: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-39"] } | |
| telemetrygen-40: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-40"] } | |
| telemetrygen-41: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-41"] } | |
| telemetrygen-42: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-42"] } | |
| telemetrygen-43: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-43"] } | |
| telemetrygen-44: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-44"] } | |
| telemetrygen-45: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-45"] } | |
| telemetrygen-46: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-46"] } | |
| telemetrygen-47: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-47"] } | |
| telemetrygen-48: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-48"] } | |
| telemetrygen-49: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-49"] } | |
| telemetrygen-50: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-50"] } | |
| telemetrygen-51: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-51"] } | |
| telemetrygen-52: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-52"] } | |
| telemetrygen-53: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-53"] } | |
| telemetrygen-54: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-54"] } | |
| telemetrygen-55: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-55"] } | |
| telemetrygen-56: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-56"] } | |
| telemetrygen-57: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-57"] } | |
| telemetrygen-58: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-58"] } | |
| telemetrygen-59: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-59"] } | |
| telemetrygen-60: { <<: *telemetrygen-base, command: ["metrics", "--otlp-insecure", "--otlp-endpoint=otel-collector:4317", "--rate=5", "--duration=1000h", "--metric-type=Sum", "--service=app-60"] } | |
| networks: | |
| otel-network: | |
| driver: bridge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| receivers: | |
| otlp: | |
| protocols: | |
| grpc: | |
| endpoint: 0.0.0.0:4317 | |
| processors: | |
| # 將 telemetrygen 產生的 Cumulative 轉成 Delta | |
| # 這樣才能讓 deltatocumulative 有事做 | |
| cumulativetodelta: | |
| batch: | |
| send_batch_size: 100 | |
| timeout: 1s | |
| deltatocumulative: | |
| max_stale: 1m | |
| # 【關鍵設定】設定極低的上限,強迫發生 Drop | |
| # telemetrygen 會送 100 個 metrics,這裡只允許 50 個 | |
| max_streams: 50 | |
| exporters: | |
| prometheus: | |
| endpoint: "0.0.0.0:8889" | |
| namespace: "poc_app" | |
| debug: | |
| verbosity: normal | |
| service: | |
| telemetry: | |
| metrics: | |
| readers: | |
| - pull: | |
| exporter: | |
| prometheus: | |
| host: "0.0.0.0" | |
| port: 8888 | |
| pipelines: | |
| metrics: | |
| receivers: [otlp] | |
| # 【修正後正確順序】 | |
| # 1. 先轉 Delta (模擬 App 行為) | |
| # 2. DeltaToCumulative 先過濾 -> 超限的在這裡就被丟棄 | |
| # 3. Batch 打包 -> 只記錄過濾後的數據點 | |
| processors: [cumulativetodelta, deltatocumulative, batch] | |
| exporters: [prometheus, debug] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| global: | |
| scrape_interval: 5s | |
| evaluation_interval: 5s | |
| scrape_configs: | |
| # Job 1: 監控 Collector 本身 (查證 Drop 和 Batch Size) | |
| - job_name: 'otel-collector-internal' | |
| static_configs: | |
| - targets: ['otel-collector:8888'] | |
| # Job 2: 監控實際輸出的數據 (查證 Exporter 輸出的量) | |
| - job_name: 'app-metrics' | |
| static_configs: | |
| - targets: ['otel-collector:8889'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment