| 1 |
# OpenTelemetry Collector internal observability |
| 2 |
|
| 3 |
The [Internal telemetry] page on OpenTelemetry's website contains the |
| 4 |
documentation for the Collector's internal observability, including: |
| 5 |
|
| 6 |
- Which types of observability are emitted by the Collector. |
| 7 |
- How to enable and configure these signals. |
| 8 |
- How to use this telemetry to monitor your Collector instance. |
| 9 |
|
| 10 |
If you need to troubleshoot the Collector, see [Troubleshooting]. |
| 11 |
|
| 12 |
Read on to learn about experimental features and the project's overall vision |
| 13 |
for internal telemetry. |
| 14 |
|
| 15 |
<!-- toc --> |
| 16 |
|
| 17 |
- [Goals of internal telemetry](#goals-of-internal-telemetry) |
| 18 |
* [Observable elements](#observable-elements) |
| 19 |
* [Impact](#impact) |
| 20 |
* [Configurable level of observability](#configurable-level-of-observability) |
| 21 |
* [Internal telemetry properties](#internal-telemetry-properties) |
| 22 |
+ [Units](#units) |
| 23 |
+ [Process for defining new metrics](#process-for-defining-new-metrics) |
| 24 |
- [Experimental trace telemetry](#experimental-trace-telemetry) |
| 25 |
|
| 26 |
<!-- tocstop --> |
| 27 |
|
| 28 |
## Goals of internal telemetry |
| 29 |
|
| 30 |
The Collector's internal telemetry is an important part of fulfilling |
| 31 |
OpenTelemetry's [project vision](vision.md). The following section explains the |
| 32 |
priorities for making the Collector an observable service. |
| 33 |
|
| 34 |
### Observable elements |
| 35 |
|
| 36 |
The following aspects of the Collector need to be observable. |
| 37 |
|
| 38 |
- [Current values] |
| 39 |
- Some of the current values and rates might be calculated as derivatives of |
| 40 |
cumulative values in the backend, so it's an open question whether to expose |
| 41 |
them separately or not. |
| 42 |
- [Cumulative values] |
| 43 |
- [Trace or log events] |
| 44 |
- For start or stop events, an appropriate hysteresis must be defined to avoid |
| 45 |
generating too many events. Note that start and stop events can't be |
| 46 |
detected in the backend simply as derivatives of current rates. The events |
| 47 |
include additional data that is not present in the current value. |
| 48 |
- [Host metrics] |
| 49 |
- Host metrics can help users determine if the observed problem in a service |
| 50 |
is caused by a different process on the same host. |
| 51 |
|
| 52 |
### Impact |
| 53 |
|
| 54 |
The impact of these observability improvements on the core performance of the |
| 55 |
Collector must be assessed. |
| 56 |
|
| 57 |
### Configurable level of observability |
| 58 |
|
| 59 |
Some metrics and traces can be high volume and users might not always want to |
| 60 |
observe them. An observability verbosity “level” allows configuration of the |
| 61 |
Collector to send more or less observability data or with even finer |
| 62 |
granularity, to allow turning on or off specific metrics. |
| 63 |
|
| 64 |
The default level of observability must be defined in a way that has |
| 65 |
insignificant performance impact on the service. |
| 66 |
|
| 67 |
### Internal telemetry properties |
| 68 |
|
| 69 |
Telemetry produced by the Collector has the following properties: |
| 70 |
|
| 71 |
- metrics produced by Collector components use the prefix `otelcol_` |
| 72 |
- metrics produced by any instrumentation library used by Collector components will *not* be prefixed with `otelcol_` |
| 73 |
- code is instrumented using the OpenTelemetry API for metrics, and traces. Logs are instrumented using zap. Telemetry is collected and produced via the OpenTelemetry Go SDK |
| 74 |
- instrumentation scope defaults to the package name of the component recording telemetry. It can be configured |
| 75 |
via the `scope_name` option in mdatagen, but the recommendation is to keep the default |
| 76 |
- metrics are defined via `metadata.yaml` except in components that have specific cases where |
| 77 |
it is not possible to do so. See the [issue](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/33523) |
| 78 |
which list such components |
| 79 |
- whenever possible, components should leverage core components or helper libraries to capture |
| 80 |
telemetry, ensuring that all components of the Collector can be consistently observed |
| 81 |
- telemetry produced by components should include attributes that identify specific instances |
| 82 |
of the components |
| 83 |
|
| 84 |
#### Units |
| 85 |
|
| 86 |
The following units should be used for metrics emitted by the Collector |
| 87 |
for the purpose of its internal telemetry: |
| 88 |
|
| 89 |
| Field type | Unit | |
| 90 |
| -------------------------------------------------------------------------- | -------------- | |
| 91 |
| Metric counting the number of log records received, processed, or exported | `{records}` | |
| 92 |
| Metric counting the number of spans received, processed, or exported | `{spans}` | |
| 93 |
| Metric counting the number of data points received, processed, or exported | `{datapoints}` | |
| 94 |
|
| 95 |
#### Process for defining new metrics |
| 96 |
|
| 97 |
Metrics in the Collector are defined via `metadata.yaml`, which is used by [mdatagen] to |
| 98 |
produce: |
| 99 |
|
| 100 |
- code to create metric instruments that can be used by components |
| 101 |
- documentation for internal metrics |
| 102 |
- a consistent prefix for all internal metrics |
| 103 |
- convenience accessors for meter and tracer |
| 104 |
- a consistent instrumentation scope for components |
| 105 |
- test methods for validating the telemetry |
| 106 |
|
| 107 |
The process to generate new metrics is to configure them via |
| 108 |
`metadata.yaml`, and run `go generate` on the component. |
| 109 |
|
| 110 |
## Experimental trace telemetry |
| 111 |
|
| 112 |
The Collector does not expose traces by default, but can be configured. |
| 113 |
The Collector's internal telemetry uses OpenTelemetry SDK. |
| 114 |
|
| 115 |
The following configuration can be used in combination with the aforementioned |
| 116 |
feature gates to emit internal metrics and traces from the Collector to an OTLP |
| 117 |
backend: |
| 118 |
|
| 119 |
```yaml |
| 120 |
service: |
| 121 |
telemetry: |
| 122 |
metrics: |
| 123 |
readers: |
| 124 |
- periodic: |
| 125 |
interval: 5000 |
| 126 |
exporter: |
| 127 |
otlp: |
| 128 |
protocol: grpc |
| 129 |
endpoint: https://backend:4317 |
| 130 |
traces: |
| 131 |
processors: |
| 132 |
- batch: |
| 133 |
exporter: |
| 134 |
otlp: |
| 135 |
protocol: grpc |
| 136 |
endpoint: https://backend2:4317 |
| 137 |
``` |
| 138 |
|
| 139 |
See the [example configuration][kitchen-sink] for additional options. |
| 140 |
|
| 141 |
> This configuration does not support emitting logs as there is no support for |
| 142 |
> [logs] in the OpenTelemetry Go SDK at this time. |
| 143 |
|
| 144 |
You can also configure the Collector to send its own traces using the OTLP |
| 145 |
exporter. Send the traces to an OTLP server running on the same Collector, so it |
| 146 |
goes through configured pipelines. For example: |
| 147 |
|
| 148 |
```yaml |
| 149 |
service: |
| 150 |
telemetry: |
| 151 |
traces: |
| 152 |
processors: |
| 153 |
batch: |
| 154 |
exporter: |
| 155 |
otlp: |
| 156 |
protocol: grpc |
| 157 |
endpoint: ${MY_POD_IP}:4317 |
| 158 |
``` |
| 159 |
|
| 160 |
[Internal telemetry]: |
| 161 |
https://opentelemetry.io/docs/collector/internal-telemetry/ |
| 162 |
[Troubleshooting]: https://opentelemetry.io/docs/collector/troubleshooting/ |
| 163 |
[issue7532]: |
| 164 |
https://github.com/open-telemetry/opentelemetry-collector/issues/7532 |
| 165 |
[issue7454]: |
| 166 |
https://github.com/open-telemetry/opentelemetry-collector/issues/7454 |
| 167 |
[logs]: https://github.com/open-telemetry/opentelemetry-go/issues/3827 |
| 168 |
[OpenTelemetry Configuration]: |
| 169 |
https://github.com/open-telemetry/opentelemetry-configuration |
| 170 |
[kitchen-sink]: |
| 171 |
https://github.com/open-telemetry/opentelemetry-configuration/blob/main/examples/kitchen-sink.yaml |
| 172 |
[Current values]: |
| 173 |
https://opentelemetry.io/docs/collector/internal-telemetry/#summary-of-values-observable-with-internal-metrics |
| 174 |
[Cumulative values]: |
| 175 |
https://opentelemetry.io/docs/collector/internal-telemetry/#summary-of-values-observable-with-internal-metrics |
| 176 |
[Trace or log events]: |
| 177 |
https://opentelemetry.io/docs/collector/internal-telemetry/#events-observable-with-internal-logs |
| 178 |
[Host metrics]: |
| 179 |
https://opentelemetry.io/docs/collector/internal-telemetry/#lists-of-internal-metrics |
| 180 |
[mdatagen]: |
| 181 |
https://github.com/open-telemetry/opentelemetry-collector/tree/main/cmd/mdatagen |