Internal telemetry

You are viewing the English version of this page because it has not yet been fully translated. Interested in helping out? See Contributing.

You can inspect the health of any OpenTelemetry Collector instance by checking its own internal telemetry. Read on to learn about this telemetry and how to configure it to help you monitor and troubleshoot the Collector.

Activate internal telemetry in the Collector

By default, the Collector exposes its own telemetry in two ways:

  • Internal metrics are exposed using a Prometheus interface which defaults to port 8888.
  • Logs are emitted to stderr by default.

Configure resource attributes

The Collector’s automatically attaches the service.name, service.version, and service.instance.id (randomly generated) resource attributes to its internal telemetry signals. These can be disabled by setting the attribute value to null (ex. service.name: null).

If you’d like to add additional resource attributes to the Collector’s internal telemetry signals (traces, metrics, and logs) you can set them under service::telemetry::resource:

service:
  telemetry:
    resource:
      attribute_key: 'attribute_value'

Configure internal metrics

OTLP exporter for internal metrics

You can configure how internal metrics are generated and exposed by the Collector. By default, the Collector generates basic metrics about itself and exposes them using the OpenTelemetry Go Prometheus exporter for scraping at http://127.0.0.1:8888/metrics.

The Collector can push its internal metrics to an OTLP backend via the following configuration:

service:
  telemetry:
    metrics:
      readers:
        - periodic:
            exporter:
              otlp:
                protocol: http/protobuf
                endpoint: https://backend:4318

For all available options, see OTLP exporter options.

Prometheus endpoint for internal metrics

Alternatively, you can expose the Prometheus endpoint to one specific or all network interfaces when needed. For containerized environments, you might want to expose this port on a public interface.

Set the Prometheus config under service::telemetry::metrics:

service:
  telemetry:
    metrics:
      readers:
        - pull:
            exporter:
              prometheus:
                host: '0.0.0.0'
                port: 8888

If you want to add additional labels to the Prometheus metrics, you can add them with prometheus::with_resource_constant_labels:

prometheus:
  host: '0.0.0.0'
  port: 8888
  with_resource_constant_labels:
    included:
      - label_key

And then reference the labels in service::telemetry::resource:

resource:
  label_key: label_value

Service address

Metric verbosity

You can adjust the verbosity of the Collector metrics output by setting the level field to one of the following values:

  • none: no telemetry is collected.
  • basic: essential service telemetry.
  • normal: the default level, adds standard indicators on top of basic.
  • detailed: the most verbose level, includes dimensions and views.

Each verbosity level represents a threshold at which certain metrics are emitted. For the complete list of metrics, with a breakdown by level, see Lists of internal metrics.

The default level for metrics output is normal. To use another level, set service::telemetry::metrics::level:

service:
  telemetry:
    metrics:
      level: detailed

Metric views

You can further configure how metrics from the Collector are emitted by using views. For example, the following configuration updates the metric named otelcol_process_uptime to emit a new name process_uptime and description:

service:
  telemetry:
    metrics:
      views:
        - selector:
            instrument_name: otelcol_process_uptime
            instrument_type:
          stream:
            name: process_uptime
            description: The amount of time the Collector has been up

You can also use views to update the resulting aggregation, attributes, and cardinality limits. For the full list of options, see the examples in the OpenTelemetry Configuration schema repository.

Configure internal logs

Log output is found in stderr. You can configure logs in the config service::telemetry::logs. The configuration options are:

Field nameDefault valueDescription
levelINFOSets the minimum enabled logging level. Other possible values are DEBUG, WARN, and ERROR.
developmentfalsePuts the logger in development mode.
encodingconsoleSets the logger’s encoding. The other possible value is json.
disable_callerfalseStops annotating logs with the calling function’s file name and line number. By default, all logs are annotated.
disable_stacktracefalseDisables automatic stacktrace capturing. Stacktraces are captured for logs at WARN level and above in development and at ERROR level and above in production.
sampling::enabledtrueSets a sampling policy.
sampling::tick10sThe interval in seconds that the logger applies to each sampling.
sampling::initial10The number of messages logged at the start of each sampling::tick.
sampling::thereafter100Sets the sampling policy for subsequent messages after sampling::initial messages are logged. When sampling::thereafter is set to N, every Nth message is logged and all others are dropped. If N is zero, the logger drops all messages after sampling::initial messages are logged.
output_paths["stderr"]A list of URLs or file paths to write logging output to.
error_output_paths["stderr"]A list of URLs or file paths to write logger errors to.
initial_fieldsA collection of static key-value pairs added to all log entries to enrich logging context. By default, there is no initial field.

You can also see logs for the Collector on a Linux systemd system using journalctl: