|
| 1 | +# Configuration file for OpenTelemetry Collector. |
| 2 | +# This file defines receivers, exporters, processors, and service pipelines for telemetry data collection and processing. |
| 3 | + |
| 4 | +receivers: |
| 5 | + # Receivers collect telemetry data from applications or other sources. |
| 6 | + |
| 7 | + otlp: # OpenTelemetry Protocol receiver. |
| 8 | + protocols: |
| 9 | + http: |
| 10 | + endpoint: 0.0.0.0:4318 # HTTP endpoint for receiving telemetry data. |
| 11 | + grpc: |
| 12 | + endpoint: 0.0.0.0:4317 # gRPC endpoint for receiving telemetry data. |
| 13 | + |
| 14 | + prometheus: # Prometheus receiver to scrape metrics from endpoints. |
| 15 | + config: |
| 16 | + scrape_configs: |
| 17 | + - job_name: otelcol-metrics |
| 18 | + scrape_interval: 60s # Frequency for scraping metrics. |
| 19 | + static_configs: |
| 20 | + - targets: ["otel-collector:8888"] # Target endpoint for metrics scraping. |
| 21 | + - job_name: spanmetrics |
| 22 | + scrape_interval: 60s # Frequency for scraping span metrics. |
| 23 | + static_configs: |
| 24 | + - targets: ["otel-collector:9999"] # Target endpoint for span metrics scraping. |
| 25 | + metric_relabel_configs: |
| 26 | + - source_labels: [span_kind] |
| 27 | + regex: SPAN_KIND_SERVER |
| 28 | + action: keep # Keep only server spans. |
| 29 | + - source_labels: [http_user_agent, request_header_user_agent, http_request_header_user_agent] |
| 30 | + regex: kube-probe/.*|Prometheus/.*|Gravitee.io/.*|ELB-HealthChecker/.* |
| 31 | + action: drop # Drop metrics generated by probes or health checkers. |
| 32 | + - regex: http_user_agent|request_header_user_agent|http_request_header_user_agent |
| 33 | + action: labeldrop # Remove specified labels. |
| 34 | + |
| 35 | + otlp/spanmetrics: # Separate receiver for span metrics. |
| 36 | + protocols: |
| 37 | + grpc: |
| 38 | + endpoint: 0.0.0.0:12345 # gRPC endpoint for receiving span metrics. |
| 39 | + |
| 40 | +exporters: |
| 41 | + # Exporters send processed telemetry data to external systems. |
| 42 | + |
| 43 | + prometheusremotewrite: |
| 44 | + endpoint: "http://prometheus:9090/api/v1/write" # Export metrics to Prometheus. |
| 45 | + |
| 46 | + logging: |
| 47 | + logLevel: debug # Log telemetry data for debugging. |
| 48 | + |
| 49 | + otlp/jaeger: |
| 50 | + endpoint: "jaeger:4317" # Export traces to Jaeger. |
| 51 | + tls: |
| 52 | + insecure: true # Disable TLS verification (for testing or internal use). |
| 53 | + |
| 54 | + prometheus/spanmetrics: |
| 55 | + endpoint: 0.0.0.0:9999 # Endpoint for exposing span metrics to Prometheus. |
| 56 | + metric_expiration: 75s # Time to keep metrics before expiring them. |
| 57 | + |
| 58 | +processors: |
| 59 | + # Processors transform telemetry data before exporting. |
| 60 | + |
| 61 | + batch: # Batch processor to group data for efficient processing. |
| 62 | + |
| 63 | + tail_sampling: # Sampling processor for traces. |
| 64 | + decision_wait: 45s # Wait time for sampling decision. |
| 65 | + num_traces: 50000 # Maximum number of traces to sample. |
| 66 | + policies: |
| 67 | + - name: ignore-http-user-agent |
| 68 | + type: string_attribute |
| 69 | + string_attribute: |
| 70 | + key: http.user_agent |
| 71 | + values: [kube-probe/*, Prometheus/*, Gravitee.io/*, ELB-HealthChecker/*] |
| 72 | + enabled_regex_matching: true |
| 73 | + invert_match: true # Include traces not matching these values. |
| 74 | + - name: sampling-50% |
| 75 | + type: probabilistic |
| 76 | + probabilistic: |
| 77 | + sampling_percentage: 50 # Sample 50% of traces. |
| 78 | + |
| 79 | + spanmetrics: # Processor for creating span metrics. |
| 80 | + dimensions: |
| 81 | + - name: http.method |
| 82 | + - name: http.status_code |
| 83 | + - name: http.user_agent |
| 84 | + - name: request.header.user-agent |
| 85 | + - name: http.request.header-user-agent |
| 86 | + latency_histogram_buckets: [2ms, 10ms, 100ms, 1s, 10s] # Define latency buckets. |
| 87 | + metrics_exporter: prometheus/spanmetrics # Export processed metrics. |
| 88 | + |
| 89 | +service: |
| 90 | + # Service defines the pipeline for processing telemetry data. |
| 91 | + |
| 92 | + telemetry: |
| 93 | + metrics: |
| 94 | + address: 0.0.0.0:8888 # Address to expose collector's own metrics. |
| 95 | + |
| 96 | + pipelines: |
| 97 | + metrics/spanmetrics: # Pipeline for span metrics. |
| 98 | + receivers: [otlp/spanmetrics] |
| 99 | + exporters: [prometheus/spanmetrics] |
| 100 | + |
| 101 | + traces: # Pipeline for trace data. |
| 102 | + receivers: [otlp] |
| 103 | + processors: [spanmetrics, tail_sampling, batch] |
| 104 | + exporters: [logging, otlp/jaeger] |
| 105 | + |
| 106 | + metrics: # Pipeline for general metrics. |
| 107 | + receivers: [otlp, prometheus] |
| 108 | + processors: [batch] |
| 109 | + exporters: [logging, prometheusremotewrite] |
0 commit comments