From 18135851d1436aeb9d4bbebcd67756f01ec53a82 Mon Sep 17 00:00:00 2001 From: Supan Adit Pratama Date: Tue, 24 Jun 2025 15:08:18 +0700 Subject: [PATCH] feat: add opentelemetry collector --- docker/opentelemetry/collector/compose.yaml | 10 +++++ docker/opentelemetry/collector/config.yaml | 45 +++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 docker/opentelemetry/collector/compose.yaml create mode 100644 docker/opentelemetry/collector/config.yaml diff --git a/docker/opentelemetry/collector/compose.yaml b/docker/opentelemetry/collector/compose.yaml new file mode 100644 index 0000000..8a61127 --- /dev/null +++ b/docker/opentelemetry/collector/compose.yaml @@ -0,0 +1,10 @@ +services: + collector: + image: otel/opentelemetry-collector-contrib:latest + ports: + - "4317:4317" # OTLP gRPC + - "55681:55681" # OTLP HTTP + - "8888:8888" # Prometheus metrics endpoint + volumes: + - ./config.yaml:/etc/otel/config.yaml + command: ["--config", "/etc/otel/config.yaml"] \ No newline at end of file diff --git a/docker/opentelemetry/collector/config.yaml b/docker/opentelemetry/collector/config.yaml new file mode 100644 index 0000000..5addb73 --- /dev/null +++ b/docker/opentelemetry/collector/config.yaml @@ -0,0 +1,45 @@ +receivers: + mysql: + endpoint: "mysql-primary.eigen-erp-test.svc.cluster.local:3306" # Replace with your MySQL host and port + username: "root" # The dedicated MySQL user + password: "eigen3m!" # Use environment variable for password for security + collection_interval: 10s # How frequently to collect metrics (e.g., 10 seconds) + initial_delay: 1s # Initial delay before starting collection + # Optional: Configure statement events for detailed query metrics + statement_events: + digest_text_limit: 120 + time_limit: 24h + limit: 250 + +processors: + # metricstransform: + # transforms: + # - include: mysql.* # Include all MySQL metrics + # match_type: regexp + # action: insert + # operations: + # - action: add_label + # new_label: cluster + # new_value: "internal.eigen.local" + batch: + send_batch_size: 10000 + timeout: 10s + +exporters: + # otlp: + # endpoint: "172.10.10.6:30641" # Or your OTLP backend endpoint (e.g., a tracing/metrics backend like Jaeger, Prometheus, or a vendor's OTLP endpoint) + # tls: + # insecure: true # Set to false and configure proper TLS for production + prometheusremotewrite: + endpoint: "http://172.10.10.6:30291/api/v1/receive" # Or your Prometheus remote write endpoint + external_labels: + cluster: internal.eigen.local + +service: + pipelines: + metrics: + receivers: [mysql] + processors: [batch] + exporters: [prometheusremotewrite] + # If you also want to collect logs or traces from other sources, you'd add + # log and trace pipelines here as well. \ No newline at end of file