otelcol.receiver.prometheus
公开预览:这是一个公开预览组件。公开预览组件可能会有重大更改,并且可能被覆盖相同用例的等效功能取代。必须将
stability.level
标志设置为public-preview
或更低才能使用该组件。
otelcol.receiver.prometheus
接收 Prometheus 指标,将其转换为 OpenTelemetry 指标格式,并将其转发到其他 otelcol.*
组件。
可以通过为多个 otelcol.receiver.prometheus
组件赋予不同的标签来指定它们。
用法
otelcol.receiver.prometheus "LABEL" {
output {
metrics = [...]
}
}
参数
otelcol.receiver.prometheus
不支持任何参数,完全通过内部块进行配置。
块
otelcol.receiver.prometheus
定义中支持以下块
层级结构 | 块 | 描述 | 必需 |
---|---|---|---|
output | output | 配置接收到的遥测数据发送到哪里。 | 是 |
output 块
output
块配置一组组件来转发生成的遥测数据。
支持以下参数
名称 | 类型 | 描述 | 默认值 | 必需 |
---|---|---|---|---|
logs | list(otelcol.Consumer) | 要发送日志的消费者列表。 | [] | 否 |
metrics | list(otelcol.Consumer) | 要发送指标的消费者列表。 | [] | 否 |
traces | list(otelcol.Consumer) | 要发送跟踪的消费者列表。 | [] | 否 |
必须指定 output
块,但其所有参数都是可选的。默认情况下,遥测数据会被丢弃。相应地配置 metrics
、logs
和 traces
参数,以便将遥测数据发送到其他组件。
导出的字段
以下字段被导出,可供其他组件引用
名称 | 类型 | 描述 |
---|---|---|
receiver | MetricsReceiver | 其他组件可用于向其发送 Prometheus 指标的值。 |
组件健康状况
只有在配置无效时,otelcol.receiver.prometheus
才会被报告为不健康。
调试信息
otelcol.receiver.prometheus
不会暴露任何特定于组件的调试信息。
示例
此示例使用 otelcol.receiver.prometheus
组件作为 Prometheus 和 OpenTelemetry 生态系统之间的桥梁。该组件暴露一个接收器,prometheus.scrape
组件使用该接收器将 Prometheus 指标数据发送到。指标在转发到 otelcol.exporter.otlp
组件并发送到支持 OTLP 的端点之前,会被转换为 OTLP 格式
prometheus.scrape "default" {
// Collect metrics from the default HTTP listen address.
targets = [{"__address__" = "127.0.0.1:12345"}]
forward_to = [otelcol.receiver.prometheus.default.receiver]
}
otelcol.receiver.prometheus "default" {
output {
metrics = [otelcol.exporter.otlp.default.input]
}
}
otelcol.exporter.otlp "default" {
client {
endpoint = sys.env("OTLP_ENDPOINT")
}
}
兼容组件
otelcol.receiver.prometheus
可以接受来自以下组件的参数
otelcol.receiver.prometheus
导出的内容可供以下组件消费
- 消费 Prometheus
MetricsReceiver
的组件
注意
某些组件的连接可能不合理,或者组件可能需要进一步配置才能使连接正常工作。有关更多详细信息,请参阅链接的文档。