OTel 收集器与导出器
了解 OpenTelemetry Collector 及其在处理、过滤和导出可观测性数据方面的作用。学习面向不同后端的各种导出器。
OTel 收集器与导出器 是 CoddyKit 上的免费 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 课时。 这是第 2 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 课程共包含 4 节课。
本课时的部分内容尚未翻译,以英文显示。
Meet the OTel Collector
The OpenTelemetry Collector is a powerful, vendor-agnostic proxy that receives, processes, and exports observability data. Think of it as a central traffic controller for your logs, metrics, and traces.
It simplifies managing your observability data, especially in complex distributed systems, by acting as an intermediary.
Why Use a Collector?
Instead of sending observability data directly from every application to different backend systems, the Collector acts as an intermediary. This offers several benefits:
- Reduced Overhead: Applications send data once to the Collector.
- Centralized Processing: Apply common transformations in one place.
- Backend Flexibility: Easily switch or add observability backends without changing application code.
Collector's Core Parts
The OpenTelemetry Collector is built from several key components, each with a specific job. Understanding these parts helps you configure it effectively:
- Receivers: How data gets IN.
- Processors: How data is TRANSFORMED.
- Exporters: How data gets OUT.
- Service: Orchestrates these components to form pipelines.
Let's look at each one individually.
Data In: Receivers
Receivers are the entry points for observability data into the Collector. They listen for data in various formats and protocols.
Think of a receiver as a data intake funnel. It's configured to accept traces, metrics, or logs from your applications, infrastructure, or other sources.
OTLP Receiver Example
The most common receiver is the OTLP receiver. OTLP stands for OpenTelemetry Protocol, which is the native format for OpenTelemetry data.
Here's how you might configure an OTLP receiver to listen for both gRPC and HTTP data:
receivers:
otlp:
protocols:
grpc:
http:Data Transform: Processors
Processors manipulate the observability data between being received and before being exported. They can enrich, filter, aggregate, or modify data.
This is where you can optimize data, reduce noise, add useful context, or even sample data to control volume.
Batch Processor Example
A very common processor is the batch processor. It groups data points (traces, metrics, or logs) together before sending them to an exporter.
Batching reduces network calls and can significantly improve performance and resource usage for both the Collector and the backend systems.
processors:
batch:
send_batch_size: 1000
timeout: 5sData Out: Exporters
Exporters are responsible for sending the processed observability data from the Collector to one or more backend systems. These backends could be a tracing system, a metrics database, or a log management platform.
The Collector supports a wide variety of exporters for different vendors and open-source tools.
OTLP Exporter Example
Just like receivers, there's also an OTLP exporter. This allows the Collector to forward data, in OpenTelemetry's native format, to another OTLP-compatible endpoint.
This is useful for chaining Collectors or sending data to a vendor's OTLP endpoint.
exporters:
otlp:
endpoint: "otel-collector.mycompany.com:4317"
tls:
insecure: trueA Simple Collector Pipeline
Here's how you'd define a simple pipeline in the Collector's configuration file, connecting a receiver, a processor, and an exporter.
The service section ties everything together, defining which receivers, processors, and exporters are used for traces, metrics, and logs.
receivers:
otlp:
protocols:
grpc:
processors:
batch:
exporters:
otlp:
endpoint: "localhost:4317"
tls:
insecure: true
service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [otlp]Check Your Understanding
Let's test your knowledge about the OpenTelemetry Collector's components.
OTel Collector Recap
You've learned that the OpenTelemetry Collector is a crucial component for managing observability data.
- It acts as a central hub, decoupling applications from observability backends.
- It uses Receivers to get data in, Processors to transform it, and Exporters to send it out.
- This architecture provides flexibility, reduces overhead, and allows for centralized data manipulation.
Next, we'll get an overview of how to instrument your applications using OpenTelemetry SDKs!
常见问题解答
「OTel 收集器与导出器」课时是免费的吗?
是的 — 「OTel 收集器与导出器」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 课程的其余内容,请升级到 CoddyKit PRO。 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 课程共包含 4 节课。
「OTel 收集器与导出器」这节课中我会学到什么?
了解 OpenTelemetry Collector 及其在处理、过滤和导出可观测性数据方面的作用。学习面向不同后端的各种导出器。 你通过在浏览器中直接运行的动手代码来练习 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry),全天候 AI 导师会在你学习这节课的过程中回答你的问题。
学习 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 需要有经验吗?
无需任何先前经验。CoddyKit 上的 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 2 节课,共 4 节。
「OTel 收集器与导出器」课时需要多长时间?
大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。
我能在这节 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 课中编写并运行代码吗?
能。每节 System Observability: Logging, Metrics & Tracing (ELK + OpenTelemetry) 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。
此课程中的所有课时
- OpenTelemetry 标准
- OTel 收集器与导出器
- 使用 OTel SDK 为应用添加检测
- 信号与语义约定