|
| 1 | +--- |
| 2 | +title: Gateway |
| 3 | +description: |
| 4 | + Why and how to send signals to a single OTLP end-point and from there to |
| 5 | + backends |
| 6 | +weight: 3 |
| 7 | +--- |
| 8 | + |
| 9 | +The gateway collector deployment pattern consists of applications (or other |
| 10 | +collectors) sending telemetry signals to a single OTLP endpoint provided by one |
| 11 | +or more collector instances running as a standalone service (for example, a |
| 12 | +deployment in Kubernetes), typically per cluster, per data center or per region. |
| 13 | + |
| 14 | +In the general case you can use an out-of-the-box load balancer to distribute |
| 15 | +the load amongst the collectors: |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | +For use cases where the processing of the telemetry data processing has to |
| 20 | +happen in a specific collector, you would use a two-tiered setup with a |
| 21 | +collector that has a pipeline configured with the [Trace ID/Service-name aware |
| 22 | +load-balancing exporter][lb-exporter] in the first tier and the collectors |
| 23 | +handling the scale out in the second tier. For example, you will need to use the |
| 24 | +load-balancing exporter when using the [Tail Sampling |
| 25 | +processor][tailsample-processor] so that all spans for a given trace reach the |
| 26 | +same collector instance where the tail sampling policy is applied. |
| 27 | + |
| 28 | +Let's have a look at such a case where we are using the load-balancing exporter: |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +1. In the app, the SDK is configured to send OTLP data to a central location. |
| 33 | +1. A collector configured using the load-balancing exporter that distributes |
| 34 | + signals to a group of collectors. |
| 35 | +1. The collectors are configured to send telemetry data to one or more backends. |
| 36 | + |
| 37 | +{{% alert title="Note" color="info" %}} Currently, the load-balancing exporter |
| 38 | +only supports pipelines of the `traces` type. {{% /alert %}} |
| 39 | + |
| 40 | +## Example |
| 41 | + |
| 42 | +For a concrete example of the centralized collector deployment pattern we first |
| 43 | +need to have a closer look at the load-balancing exporter. It has two main |
| 44 | +configuration fields: |
| 45 | + |
| 46 | +- The `resolver`, which determines where to find the downstream collectors (or: |
| 47 | + backends). If you use the `static` sub-key here, you will have to manually |
| 48 | + enumerate the collector URLs. The other supported resolver is the DNS resolver |
| 49 | + which will periodically check for updates and resolve IP addresses. For this |
| 50 | + resolver type, the `hostname` sub-key specifies the hostname to query in order |
| 51 | + to obtain the list of IP addresses. |
| 52 | +- With the `routing_key` field you tell the load-balancing exporter to route |
| 53 | + spans to specific downstream collectors. If you set this field to `traceID` |
| 54 | + (default) then the Load-balancing exporter exports spans based on their |
| 55 | + `traceID`. Otherwise, if you use `service` as the value for `routing_key`, it |
| 56 | + exports spans based on their service name which is useful when using |
| 57 | + connectors like the [Span Metrics connector][spanmetrics-connector], so all |
| 58 | + spans of a service will be send to the same downstream collector for metric |
| 59 | + collection, guaranteeting accurate aggregations. |
| 60 | + |
| 61 | +The first-tier collector servicing the OTLP endpoint would be configured as |
| 62 | +shown below: |
| 63 | + |
| 64 | +<!-- prettier-ignore-start --> |
| 65 | +{{< tabpane lang=yaml persistLang=false >}} |
| 66 | +{{< tab Static >}} |
| 67 | +receivers: |
| 68 | + otlp: |
| 69 | + protocols: |
| 70 | + grpc: |
| 71 | + |
| 72 | +exporters: |
| 73 | + loadbalancing: |
| 74 | + protocol: |
| 75 | + otlp: |
| 76 | + insecure: true |
| 77 | + resolver: |
| 78 | + static: |
| 79 | + hostnames: |
| 80 | + - collector-1.example.com:4317 |
| 81 | + - collector-2.example.com:5317 |
| 82 | + - collector-3.example.com |
| 83 | + |
| 84 | +service: |
| 85 | + pipelines: |
| 86 | + traces: |
| 87 | + receivers: [otlp] |
| 88 | + exporters: [loadbalancing] |
| 89 | +{{< /tab >}} |
| 90 | +{{< tab DNS >}} |
| 91 | +receivers: |
| 92 | + otlp: |
| 93 | + protocols: |
| 94 | + grpc: |
| 95 | + |
| 96 | +exporters: |
| 97 | + loadbalancing: |
| 98 | + protocol: |
| 99 | + otlp: |
| 100 | + insecure: true |
| 101 | + resolver: |
| 102 | + dns: |
| 103 | + hostname: collectors.example.com |
| 104 | + |
| 105 | +service: |
| 106 | + pipelines: |
| 107 | + traces: |
| 108 | + receivers: [otlp] |
| 109 | + exporters: [loadbalancing] |
| 110 | +{{< /tab >}} |
| 111 | +{{< tab "DNS with service" >}} |
| 112 | +receivers: |
| 113 | + otlp: |
| 114 | + protocols: |
| 115 | + grpc: |
| 116 | + |
| 117 | +exporters: |
| 118 | + loadbalancing: |
| 119 | + routing_key: "service" |
| 120 | + protocol: |
| 121 | + otlp: |
| 122 | + insecure: true |
| 123 | + resolver: |
| 124 | + dns: |
| 125 | + hostname: collectors.example.com |
| 126 | + port: 5317 |
| 127 | + |
| 128 | +service: |
| 129 | + pipelines: |
| 130 | + traces: |
| 131 | + receivers: [otlp] |
| 132 | + exporters: [loadbalancing] |
| 133 | +{{< /tab >}} |
| 134 | +{{< /tabpane>}} |
| 135 | +<!-- prettier-ignore-end --> |
| 136 | + |
| 137 | +The load-balancing exporter emits metrics including |
| 138 | +`otelcol_loadbalancer_num_backends` and `otelcol_loadbalancer_backend_latency` |
| 139 | +that you can use for health and performance monitoring of the OTLP endpoint |
| 140 | +collector. |
| 141 | + |
| 142 | +## Tradeoffs |
| 143 | + |
| 144 | +Pros: |
| 145 | + |
| 146 | +- Separation of concerns such as centrally managed credentials |
| 147 | +- Centralized policy management (for example, filtering certain logs or |
| 148 | + sampling) |
| 149 | + |
| 150 | +Cons: |
| 151 | + |
| 152 | +- It's one more thing to maintain and that can fail (complexity) |
| 153 | +- Added latency in case of cascaded collectors |
| 154 | +- Higher overall resource usage (costs) |
| 155 | + |
| 156 | +[instrumentation]: /docs/instrumentation/ |
| 157 | +[otlp]: /docs/reference/specification/protocol/ |
| 158 | +[collector]: /docs/collector/ |
| 159 | +[instrument-java-metrics]: /docs/instrumentation/java/manual/#metrics |
| 160 | +[otlp-exporter]: /docs/reference/specification/protocol/exporter/ |
| 161 | +[java-otlp-example]: |
| 162 | + https://github.com/open-telemetry/opentelemetry-java-docs/tree/main/otlp |
| 163 | +[py-otlp-example]: |
| 164 | + https://opentelemetry-python.readthedocs.io/en/stable/examples/metrics/instruments/README.html |
| 165 | +[lb-exporter]: |
| 166 | + https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/loadbalancingexporter |
| 167 | +[tailsample-processor]: |
| 168 | + https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/tailsamplingprocessor |
| 169 | +[spanmetrics-connector]: |
| 170 | + https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/spanmetricsconnector |
0 commit comments