安装收集器

您可以在各种操作系统和体系结构上部署OpenTelemetry Collector。以下说明展示了如何下载和安装最新稳定版的Collector。

如果您对适用于OpenTelemetry Collector的部署模型、组件和存储库不太熟悉,请先阅读[数据收集][]和[部署方法][]页面。

Docker

以下命令拉取Docker镜像并在容器中运行Collector。请将0.88.0替换为您要运行的Collector的版本。

docker pull otel/opentelemetry-collector-contrib:0.88.0
docker run otel/opentelemetry-collector-contrib:0.88.0
docker pull ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.88.0
docker run ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.88.0

要从您的工作目录加载自定义配置文件,请将该文件挂载为一个卷:

docker run -v $(pwd)/config.yaml:/etc/otelcol-contrib/config.yaml otel/opentelemetry-collector-contrib:0.88.0
docker run -v $(pwd)/config.yaml:/etc/otelcol-contrib/config.yaml ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.88.0

Docker Compose

您可以将OpenTelemetry Collector添加到现有的 docker-compose.yaml 文件中,如下例所示:

otel-collector:
  image: otel/opentelemetry-collector-contrib
  volumes:
    - ./otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml
  ports:
    - 1888:1888 # pprof扩展
    - 8888:8888 # Collector公开的Prometheus指标
    - 8889:8889 # Prometheus导出器指标
    - 13133:13133 # health_check扩展
    - 4317:4317 # OTLP gRPC接收器
    - 4318:4318 # OTLP http接收器
    - 55679:55679 # zpages扩展

Kubernetes

以下命令将一个代理作为守护程序集部署,并部署一个单独的网关实例:

kubectl apply -f https://raw.githubusercontent.com/open-telemetry/opentelemetry-collector/main/examples/k8s/otel-config.yaml

上述示例是作为起点来使用的,可以在实际生产使用之前进行扩展和定制。对于可用于生产环境的自定义和安装,参见OpenTelemetry Helm Charts

您还可以使用OpenTelemetry Operator来配置和维护OpenTelemetry Collector实例,该实例具有自动升级处理、基于OpenTelemetry配置的“Service”配置、自动侧车注入到部署等功能。

有关如何在Kubernetes中使用Collector的指南,请参阅Kubernetes入门

Nomad

您可以在Getting Started with OpenTelemetry on HashiCorp Nomad中找到部署Collector作为代理、网关以及完整演示的参考作业文件。

Linux

每个Collector发布都包括了适用于Linux amd64/arm64/i386系统的APK、DEB和RPM包。您可以在安装后在/etc/otelcol/config.yaml中找到默认配置。

注意: 需要systemd来进行自动服务配置。

APK安装

在Alpine系统上开始运行以下命令:

apk update
apk add wget shadow
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.88.0/otelcol_0.88.0_linux_amd64.apk
apk add --allow-untrusted otelcol_0.88.0_linux_amd64.apk
apk update
apk add wget shadow
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.88.0/otelcol_0.88.0_linux_arm64.apk
apk add --allow-untrusted otelcol_0.88.0_linux_arm64.apk
apk update
apk add wget shadow
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.88.0/otelcol_0.88.0_linux_386.apk
apk add --allow-untrusted otelcol_0.88.0_linux_386.apk

DEB安装

在Debian系统上开始运行以下命令:

sudo apt-get update
sudo apt-get -y install wget systemctl
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.88.0/otelcol_0.88.0_linux_amd64.deb
sudo dpkg -i otelcol_0.88.0_linux_amd64.deb
sudo apt-get update
sudo apt-get -y install wget systemctl
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.88.0/otelcol_0.88.0_linux_arm64.deb
sudo dpkg -i otelcol_0.88.0_linux_arm64.deb
sudo apt-get update
sudo apt-get -y install wget systemctl
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.88.0/otelcol_0.88.0_linux_386.deb
sudo dpkg -i otelcol_0.88.0_linux_386.deb

RPM安装

在Red Hat系统上开始运行以下命令:

sudo yum update
sudo yum -y install wget systemctl
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.88.0/otelcol_0.88.0_linux_amd64.rpm
sudo rpm -ivh otelcol_0.88.0_linux_amd64.rpm
sudo yum update
sudo yum -y install wget systemctl
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.88.0/otelcol_0.88.0_linux_arm64.rpm
sudo rpm -ivh otelcol_0.88.0_linux_arm64.rpm
sudo yum update
sudo yum -y install wget systemctl
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.88.0/otelcol_0.88.0_linux_386.rpm
sudo rpm -ivh otelcol_0.88.0_linux_386.rpm

手动Linux安装

各个架构的Linux [发布][]可用。您可以下载包含二进制文件的文件,并手动在计算机上安装:

curl --proto '=https' --tlsv1.2 -fOL https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.88.0/otelcol_0.88.0_linux_amd64.tar.gz
tar -xvf otelcol_0.88.0_linux_amd64.tar.gz
curl --proto '=https' --tlsv1.2 -fOL https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.88.0/otelcol_0.88.0_linux_arm64.tar.gz
tar -xvf otelcol_0.88.0_linux_arm64.tar.gz
curl --proto '=https' --tlsv1.2 -fOL https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.88.0/otelcol_0.88.0_linux_386.tar.gz
tar -xvf otelcol_0.88.0_linux_386.tar.gz
curl --proto '=https' --tlsv1.2 -fOL https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.88.0/otelcol_0.88.0_linux_ppc64le.tar.gz
tar -xvf otelcol_0.88.0_linux_ppc64le.tar.gz

自动服务配置

安装后,默认情况下,otelcol systemd服务会在--config=/etc/otelcol/config.yaml选项的情况下启动。

要使用其他设置,请在/etc/otelcol/otelcol.conf systemd环境文件中将OTELCOL_OPTIONS变量设置为相应的命令行选项。您可以运行/usr/bin/otelcol --help查看所有可用选项。您可以将其他环境变量传递给otelcol服务,只需将它们添加到该文件中。

如果修改了Collector配置文件或/etc/otelcol/otelcol.conf,请运行以下命令来重启otelcol服务以应用更改:

sudo systemctl restart otelcol

要检查otelcol服务的输出,请运行:

sudo journalctl -u otelcol

macOS

macOS [发布][]适用于Intel和ARM系统。发布以gzipped tar包(.tar.gz)的形式打包。要解压它们,请运行以下命令:

curl --proto '=https' --tlsv1.2 -fOL https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.88.0/otelcol_0.88.0_darwin_amd64.tar.gz
tar -xvf otelcol_0.88.0_darwin_amd64.tar.gz
curl --proto '=https' --tlsv1.2 -fOL https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.88.0/otelcol_0.88.0_darwin_arm64.tar.gz
tar -xvf otelcol_0.88.0_darwin_arm64.tar.gz

每个Collector发布都包含一个otelcol可执行文件,解压后可以运行。

Windows

Windows [发布][]打包为gzipped tar包(.tar.gz)。每个Collector发布都包含一个otelcol.exe可执行文件,解压后可以运行。

源码构建

您可以使用以下命令基于本地操作系统构建最新的Collector版本:

git clone https://github.com/open-telemetry/opentelemetry-collector.git
cd opentelemetry-collector
make install-tools
make otelcorecol
最后修改 December 10, 2023: translate (a4350d6e)