|
| 1 | +.. _collector-common-config-http: |
| 2 | + |
| 3 | +********************************************************************************* |
| 4 | +Configure HTTP |
| 5 | +********************************************************************************* |
| 6 | + |
| 7 | +HTTP exposes a variety of settings you can adjust within individual receivers or exporters of the Collector. |
| 8 | + |
| 9 | +Configure HTTP clients |
| 10 | +============================================================================================= |
| 11 | + |
| 12 | +To configure HTTP clients in :ref:`exporters <otel-components-exporters>` use these settings: |
| 13 | + |
| 14 | +.. note:: Client configuration supports TLS. For more information, see :ref:`collector-common-config-tls`. |
| 15 | + |
| 16 | +* ``endpoint``. Address and port for this connection |
| 17 | + |
| 18 | +* ``tls``. See :ref:`collector-common-config-tls` |
| 19 | + |
| 20 | +* ``headers``. Name-value pairs added to the HTTP request headers |
| 21 | + |
| 22 | + * Certain headers such as Content-Length and Connection are automatically written when needed. |
| 23 | + |
| 24 | + * The ``Host`` header is automatically derived from the endpoint value. However, this automatic assignment can be overridden by explicitly setting the ``Host`` field in the ``headers`` field. |
| 25 | + |
| 26 | + * If the ``Host`` header is provided then it overrides ``Host`` field in ``Request``. For more information see :new-page:`Go's Request <https://pkg.go.dev/net/http#Request>`. |
| 27 | + |
| 28 | +* ``read_buffer_size`` |
| 29 | + |
| 30 | + * For more information see :new-page:`Go's Transport <https://pkg.go.dev/net/http#Transport>`. |
| 31 | + |
| 32 | +* ``timeout`` |
| 33 | + |
| 34 | + * For more information see :new-page:`Go's Client <https://pkg.go.dev/net/http#Client>`. |
| 35 | + |
| 36 | +* ``write_buffer_size`` |
| 37 | + |
| 38 | + * For more information see :new-page:`Go's Transport <https://pkg.go.dev/net/http#Transport>`. |
| 39 | + |
| 40 | +* ``compression``. Compression type to use |
| 41 | + |
| 42 | + * Compression type valid values are ``deflate``, ``gzip``, ``snappy``, ``zlib``, ``zstd``, and ``none``. |
| 43 | + |
| 44 | + * If compression is set to ``none``, all data is treated as uncompressed, and any other inputs cause an error. |
| 45 | + |
| 46 | +* ``max_idle_conns`` |
| 47 | + |
| 48 | + * For more information see :new-page:`Go's Transport <https://pkg.go.dev/net/http#Transport>`. |
| 49 | + |
| 50 | +* ``max_idle_conns_per_host`` |
| 51 | + |
| 52 | + * For more information see :new-page:`Go's Transport <https://pkg.go.dev/net/http#Transport>`. |
| 53 | + |
| 54 | +* ``max_conns_per_host`` |
| 55 | + |
| 56 | + * For more information see :new-page:`Go's Transport <https://pkg.go.dev/net/http#Transport>`. |
| 57 | + |
| 58 | +* ``idle_conn_timeout`` |
| 59 | + |
| 60 | + * For more information see :new-page:`Go's Transport <https://pkg.go.dev/net/http#Transport>`. |
| 61 | + |
| 62 | +* ``auth``. See :ref:`collector-common-config-auth` |
| 63 | + |
| 64 | +* ``disable_keep_alives`` |
| 65 | + |
| 66 | + * For more information see :new-page:`Go's Transport <https://pkg.go.dev/net/http#Transport>`. |
| 67 | + |
| 68 | +* ``http2_read_idle_timeout`` |
| 69 | + |
| 70 | + * For more information see :new-page:`Go's Transport <https://pkg.go.dev/net/http#Transport>`. |
| 71 | + |
| 72 | +* ``http2_ping_timeout`` |
| 73 | + |
| 74 | + * For more information see :new-page:`Go's Transport <https://pkg.go.dev/net/http#Transport>`. |
| 75 | + |
| 76 | +* ``cookies`` |
| 77 | + |
| 78 | + * [``enabled``]. If enabled, the client stores cookies from server responses and reuse them in subsequent requests. |
| 79 | + |
| 80 | + * For more information see :new-page:`Go's CookieJar type <https://pkg.go.dev/net/http#CookieJar>` documentation. |
| 81 | + |
| 82 | +For example: |
| 83 | + |
| 84 | +.. code-block:: yaml |
| 85 | +
|
| 86 | + exporter: |
| 87 | + otlphttp: |
| 88 | + endpoint: otelcol2:55690 |
| 89 | + auth: |
| 90 | + authenticator: some-authenticator-extension |
| 91 | + tls: |
| 92 | + ca_file: ca.pem |
| 93 | + cert_file: cert.pem |
| 94 | + key_file: key.pem |
| 95 | + headers: |
| 96 | + test1: "value1" |
| 97 | + "test 2": "value 2" |
| 98 | + compression: zstd |
| 99 | + cookies: |
| 100 | + enabled: true |
| 101 | +
|
| 102 | +Configure HTTP servers |
| 103 | +============================================================================================= |
| 104 | + |
| 105 | +To configure HTTP servers in :ref:`collector receivers <otel-components-receivers>` use these settings: |
| 106 | + |
| 107 | +* ``cors``. Configure CORS to allow the receiver to accept traces from web browsers, even if the receiver is hosted at a different origin |
| 108 | + |
| 109 | + * If left blank or set to ``null``, CORS is not enabled. |
| 110 | + |
| 111 | + * See the list of :new-page:`CORS parameters <https://github.com/rs/cors#parameters>`. |
| 112 | + |
| 113 | + * ``allowed_origins``. List of origins allowed to send requests to the receiver. An origin may contain a wildcard ``*`` to replace 0 or more characters. To allow any origin, set ``["*"]``. If no origins are listed, CORS will not be enabled. |
| 114 | + |
| 115 | + * ``allowed_headers``. Allow CORS requests to include headers outside the :new-page:`default safelist <https://developer.mozilla.org/en-US/docs/Glossary/CORS-safelisted_request_header>`. By default, safelist headers and X-Requested-With are allowed. To allow any request header, set to ``["*"]``. |
| 116 | + |
| 117 | + * ``max_age``. Sets the value of the ``Access-Control-Max-Age`` header, allowing clients to cache the response to CORS preflight requests. If not set, browsers use a default of 5 seconds. See more at :new-page:`Access-Control-Max-Age <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age>`. |
| 118 | + |
| 119 | +* ``endpoint`` |
| 120 | + |
| 121 | + * For valid syntax see :new-page:`gRPC Name Resolution <https://github.com/grpc/grpc/blob/master/doc/naming.md>`. |
| 122 | + |
| 123 | +* ``max_request_body_size``. ``20971520`` (20MiB) by default. Configures the maximum allowed body size in bytes for a single request |
| 124 | + |
| 125 | +* ``compression_algorithms`` |
| 126 | + |
| 127 | +* ``tls``. See :ref:`collector-common-config-tls` |
| 128 | + |
| 129 | +* ``auth``. See :ref:`collector-common-config-auth` |
| 130 | + |
| 131 | + * ``request_params``. List of query parameter names to add to the auth context, along with the HTTP headers. |
| 132 | + |
| 133 | +.. note:: You can enable the :ref:`attributes-processor` to append any http header using a custom key. You also need to enable ``"include_metadata"``. |
| 134 | + |
| 135 | +For example: |
| 136 | + |
| 137 | +.. code-block:: yaml |
| 138 | +
|
| 139 | + receivers: |
| 140 | + otlp: |
| 141 | + protocols: |
| 142 | + http: |
| 143 | + include_metadata: true |
| 144 | + auth: |
| 145 | + request_params: |
| 146 | + - token |
| 147 | + authenticator: some-authenticator-extension |
| 148 | + cors: |
| 149 | + allowed_origins: |
| 150 | + - https://foo.bar.com |
| 151 | + - https://*.test.com |
| 152 | + allowed_headers: |
| 153 | + - Example-Header |
| 154 | + max_age: 7200 |
| 155 | + endpoint: 0.0.0.0:55690 |
| 156 | + compression_algorithms: ["", "gzip"] |
| 157 | +
|
| 158 | + processors: |
| 159 | + attributes: |
| 160 | + actions: |
| 161 | + - key: http.client_ip |
| 162 | + from_context: X-Forwarded-For |
| 163 | + action: upsert |
| 164 | +
|
| 165 | +Learn more |
| 166 | +============================================================================================= |
| 167 | + |
| 168 | +For more details on the available settings refer to :new-page:`HTTP Configuration Settings <https://github.com/open-telemetry/opentelemetry-collector/tree/main/config/confighttp>` in OTel's GitHub repo. |
0 commit comments