Geavanceerd
Zoeken inInstallatiegidsen
Zo zoek je
  • Plak een foutmelding tussen aanhalingstekens, bijv. "permission denied", om de oplossingstabel te vinden.
  • Kies een gebied en een deel van de gids (installeren, eerste instellingen, dagelijks gebruik, beveiliging, oplossingen) om direct naar de juiste stap te gaan.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

Gids 84OpenTelemetry Collector · Monitoring

Install and set up the OpenTelemetry Collector

OpenTelemetry (OTel) is the open standard for traces, metrics and logs. The Collector is the vendor-neutral pipe in the middle: apps and hosts send telemetry to it, it cleans and enriches the data, and it sends it to any backend — Prometheus, Grafana Tempo, Jaeger, Loki, Elasticsearch or a SaaS tool. Change the backend without touching the apps. This guide installs the Collector (contrib distribution) on RHEL and Ubuntu, writes a pipeline for OTLP from apps, host metrics and log files, protects memory, removes sensitive data, and covers checks and fixes.

  • 9 Lessen
  • 12 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

84.1

Know it before you install

A pipeline = receivers (how data comes in) → processors (change it) → exporters (where it goes), one pipeline per signal (traces, metrics, logs). Extensions add health checks and debugging. Apps send with the OTLP protocol (gRPC 4317, HTTP 4318).

ItemValue
Distributionsotelcol (core) and **otelcol-contrib** (many more receivers/exporters — use this one)
Packages.rpm / .deb from github.com/open-telemetry/opentelemetry-collector-releases/releases
Serviceotelcol-contrib.service
Config/etc/otelcol-contrib/config.yaml
Ports4317 (OTLP gRPC), 4318 (OTLP HTTP), 13133 (health), 8888 (own metrics)
In KubernetesHelm chart open-telemetry/opentelemetry-collector or the OTel Operator

84.2

Install on RHEL and Ubuntu

Choose the version from the releases page:

OVER=0.138.0
curl -fsSLO https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v$OVER/otelcol-contrib_${OVER}_linux_amd64.rpm
dnf -y install ./otelcol-contrib_${OVER}_linux_amd64.rpm
curl -fsSLO https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v$OVER/otelcol-contrib_${OVER}_linux_amd64.deb
apt-get install -y ./otelcol-contrib_${OVER}_linux_amd64.deb
otelcol-contrib --version
systemctl status otelcol-contrib --no-pager

(Use the .rpm lines on RHEL, the .deb lines on Ubuntu.)

84.3

First configuration: one pipeline for all signals

Apps send OTLP; the host sends its own metrics and logs; traces go to Tempo/Jaeger, metrics to Prometheus, logs to Loki:

/etc/otelcol-contrib/config.yaml
extensions:
  health_check:
    endpoint: 127.0.0.1:13133
 
receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318
  hostmetrics:
    collection_interval: 30s
    scrapers:
      cpu: {}
      memory: {}
      disk: {}
      filesystem: {}
      network: {}
      load: {}
  filelog:
    include: [/var/log/nginx/access.log]
    start_at: end
 
processors:
  memory_limiter:
    check_interval: 1s
    limit_percentage: 80
    spike_limit_percentage: 20
  resourcedetection:
    detectors: [env, system]
  attributes/scrub:
    actions:
      - key: http.request.header.authorization
        action: delete
      - key: user.email
        action: hash
  batch: {}
 
exporters:
  otlphttp/tempo:
    endpoint: http://tempo.example.com:4318
  prometheusremotewrite:
    endpoint: http://prometheus.example.com:9090/api/v1/write
  otlphttp/loki:
    endpoint: http://loki.example.com:3100/otlp
  debug:
    verbosity: basic
 
service:
  extensions: [health_check]
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter, resourcedetection, attributes/scrub, batch]
      exporters: [otlphttp/tempo]
    metrics:
      receivers: [otlp, hostmetrics]
      processors: [memory_limiter, resourcedetection, batch]
      exporters: [prometheusremotewrite]
    logs:
      receivers: [otlp, filelog]
      processors: [memory_limiter, resourcedetection, attributes/scrub, batch]
      exporters: [otlphttp/loki]
PartWhy
memory_limiter firstRefuses data before the Collector runs out of memory.
batch lastSends data in batches — fewer, bigger requests.
resourcedetectionAdds host.name and environment attributes to everything.
attributes/scrubDeletes or hashes sensitive fields before data leaves.
One pipeline per signalTraces, metrics and logs can go to different backends.

(Prometheus must accept remote write: start it with --web.enable-remote-write-receiver. Loki 3 accepts OTLP on /otlp.)

Check and start; open 4317/4318 only for app networks:

otelcol-contrib validate --config /etc/otelcol-contrib/config.yaml
usermod -aG adm otelcol-contrib
systemctl restart otelcol-contrib
curl -s http://127.0.0.1:13133/
{"status":"Server available", …}
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.1.0/24" port port="4317-4318" protocol="tcp" accept'
firewall-cmd --reload

(adm lets the Collector user read /var/log files on Ubuntu; on RHEL check the file group and modes.)

84.4

Send data from an app

Most languages have OTel SDKs and auto-instrumentation. Only environment variables are needed:

export OTEL_SERVICE_NAME=shop-api
export OTEL_RESOURCE_ATTRIBUTES=deployment.environment=prod
export OTEL_EXPORTER_OTLP_ENDPOINT=http://otel.example.com:4318
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
pip install opentelemetry-distro opentelemetry-exporter-otlp
opentelemetry-bootstrap -a install
opentelemetry-instrument python app.py

84.5

Daily use: the commands and the real uses

journalctl -u otelcol-contrib -f
curl -s http://127.0.0.1:8888/metrics | grep -E 'otelcol_(receiver_accepted|exporter_sent|exporter_send_failed)_' | head
curl -s http://127.0.0.1:13133/
otelcol-contrib validate --config /etc/otelcol-contrib/config.yaml
otelcol-contrib components | head -40

Add the debug exporter to a pipeline for a few minutes to see what arrives in the log.

Real uses at work:

  • One agent per host (or a DaemonSet in Kubernetes) plus a central gateway Collector.
  • Vendor freedom: switch from one APM/observability vendor to another by changing exporters.
  • Data hygiene: remove secrets and personal data, drop noisy spans, sample traces (tail_sampling).

84.6

Make it safe

Security checklist:

  • OTLP ports only from app networks; TLS (and auth with the bearertokenauth or oidc extension) when data crosses networks.
  • Scrub sensitive attributes (tokens, cookies, emails) in the Collector.
  • memory_limiter in every pipeline; watch otelcol_exporter_send_failed_*.
  • Health and metrics endpoints on localhost or the monitoring network only.
  • Pin the Collector version; read the changelog (components change between versions).

84.7

Update and remove

Install the new .rpm/.deb the same way (dnf install ./… / apt install ./…), then validate the config and restart. Remove: dnf remove otelcol-contrib / apt purge otelcol-contrib.

Commando's in deze les

84.8

Fix common problems

ProblemCauseFix
Service does not start: 'exporters' unknown typeThe component is not in this distribution (core vs contrib).Use otelcol-contrib; otelcol-contrib components.
validate failsYAML indentation, or a component used in a pipeline but not defined.Read the error line; every name in pipelines must exist above.
No data from appsWrong endpoint/port/protocol (gRPC 4317 vs HTTP 4318), or firewall.Match OTEL_EXPORTER_OTLP_PROTOCOL and the port; test with curl -v http://HOST:4318/v1/traces.
data refused due to high memory usagememory_limiter protecting the process.More memory, smaller batches, sampling; check the backend is fast enough.
Exporter errors 4xx/5xxBackend URL, auth or format wrong.Read the log; check the backend endpoint (for example /otlp for Loki, remote write enabled in Prometheus).
permission denied reading log filesThe Collector user can not read them.Add it to the right group; check modes.

84.9

Next steps

1Why is memory_limiter the first processor?

It must refuse data before other processors use memory, so the Collector does not crash.

2How do apps find the Collector without code changes?

With environment variables like OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_SERVICE_NAME plus auto-instrumentation.

Alle commando's in dit hoofdstuk