# Copyright 2024 RustFS Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

receivers:
  otlp:
    protocols:
      grpc: # OTLP gRPC receiver
        endpoint: 0.0.0.0:4317
      http: # OTLP HTTP receiver
        endpoint: 0.0.0.0:4318

processors:
  batch: # Batch processor to improve throughput
    timeout: 5s
    send_batch_size: 1000
    metadata_keys: [ ]
    metadata_cardinality_limit: 1000
  memory_limiter:
    check_interval: 1s
    limit_mib: 512
  transform/logs:
    log_statements:
      - context: log
        statements:
          # Extract Body as attribute "message"
          - set(attributes["message"], body.string)
          # Retain the original Body
          - set(attributes["log.body"], body.string)

exporters:
  otlp/traces: # OTLP exporter for trace data
    endpoint: "http://jaeger:4317"  # OTLP gRPC endpoint for Jaeger
    tls:
      insecure: true  # TLS is disabled in the development environment and a certificate needs to be configured in the production environment.
    compression: gzip  # Enable compression to reduce network bandwidth
    retry_on_failure:
      enabled: true  # Enable retry on failure
      initial_interval: 1s  # Initial interval for retry
      max_interval: 30s  # Maximum interval for retry
      max_elapsed_time: 300s  # Maximum elapsed time for retry
    sending_queue:
      enabled: true  # Enable sending queue
      num_consumers: 10  # Number of consumers
      queue_size: 5000  # Queue size
  otlp/tempo: # OTLP exporter for trace data
    endpoint: "http://tempo:4317"  # OTLP gRPC endpoint for tempo
    tls:
      insecure: true  # TLS is disabled in the development environment and a certificate needs to be configured in the production environment.
    compression: gzip  # Enable compression to reduce network bandwidth
    retry_on_failure:
      enabled: true  # Enable retry on failure
      initial_interval: 1s  # Initial interval for retry
      max_interval: 30s  # Maximum interval for retry
      max_elapsed_time: 300s  # Maximum elapsed time for retry
    sending_queue:
      enabled: true  # Enable sending queue
      num_consumers: 10  # Number of consumers
      queue_size: 5000  # Queue size
  prometheus: # Prometheus exporter for metrics data
    endpoint: "0.0.0.0:8889"  # Prometheus scraping endpoint
    namespace: "metrics"  # indicator prefix
    send_timestamps: true  # Send timestamp
    metric_expiration: 5m  # Metric expiration time
    resource_to_telemetry_conversion:
      enabled: true  # Enable resource to telemetry conversion
  otlphttp/loki: # Loki exporter for log data
    endpoint: "http://loki:3100/otlp"
    tls:
      insecure: true
    compression: gzip  # Enable compression to reduce network bandwidth
extensions:
  health_check:
    endpoint: 0.0.0.0:13133
  pprof:
    endpoint: 0.0.0.0:1888
  zpages:
    endpoint: 0.0.0.0:55679
service:
  extensions: [ health_check, pprof, zpages ]  # Enable extension
  pipelines:
    traces:
      receivers: [ otlp ]
      processors: [ memory_limiter, batch ]
      exporters: [ otlp/traces, otlp/tempo ]
    metrics:
      receivers: [ otlp ]
      processors: [ batch ]
      exporters: [ prometheus ]
    logs:
      receivers: [ otlp ]
      processors: [ batch, transform/logs ]
      exporters: [ otlphttp/loki ]
  telemetry:
    logs:
      level: "debug"  # Collector log level
      encoding: "json"  # Log encoding: console or json
    metrics:
      level: "detailed" # Can be basic, normal, detailed
      readers:
        - periodic:
            exporter:
              otlp:
                protocol: http/protobuf
                endpoint: http://otel-collector:4318
        - pull:
            exporter:
              prometheus:
                host: '0.0.0.0'
                port: 8888


