pyroscope.receive_http
公开预览:这是一个公开预览组件。公开预览组件可能会发生重大更改,并可能被涵盖相同用例的等效功能取代。必须将
stability.level
标志设置为public-preview
或更低才能使用该组件。
pyroscope.receive_http
通过 HTTP 接收 profile 数据,并将其转发到能够接收 profile 数据的 pyroscope.*
组件。
暴露的 HTTP API 与 Pyroscope 的 HTTP 摄取 API 和 pushv1.PusherService Connect API 兼容。这使得 pyroscope.receive_http
可以充当 Pyroscope profile 数据的代理,从而实现 profile 数据的灵活路由和分发。
用法
pyroscope.receive_http "<LABEL>" {
http {
listen_address = "<LISTEN_ADDRESS>"
listen_port = "<PORT>"
}
forward_to = <RECEIVER_LIST>
}
该组件启动一个 HTTP 服务器,支持以下端点。
POST /ingest
- 将 profile 数据发送到该组件,该组件会根据forward_to argument
参数的配置将其转发给接收者。请求格式必须与 Pyroscope 摄取 API 的格式匹配。POST /push.v1.PusherService/Push
- 将 profile 数据发送到该组件,该组件会根据forward_to argument
参数的配置将其转发给接收者。请求格式必须与 Pyroscope pushv1.PusherService Connect API 的格式匹配。
参数
您可以将以下参数与 pyroscope.receive_http
一起使用
名称 | 类型 | 描述 | 默认值 | 必需 |
---|---|---|---|---|
forward_to | list(ProfilesReceiver) | 要将 profile 数据发送到的接收者列表。 | 是 |
块
您可以将以下块与 pyroscope.receive_http
一起使用
名称 | 描述 | 必需 |
---|---|---|
http | 配置接收请求的 HTTP 服务器。 | 否 |
http
http
块用于配置 HTTP 服务器。
您可以使用以下参数配置 http
块。任何被省略的字段将采用其默认值。
名称 | 类型 | 描述 | 默认值 | 必需 |
---|---|---|---|---|
conn_limit | int | 最大同时 HTTP 连接数。默认值为 100。 | 0 | 否 |
listen_address | string | 服务器监听新连接的网络地址。默认接受所有传入连接。 | "" | 否 |
listen_port | int | 服务器监听新连接的端口号。 | 8080 | 否 |
server_idle_timeout | duration | HTTP 服务器的空闲超时时间。 | "120s" | 否 |
server_read_timeout | duration | HTTP 服务器的读取超时时间。 | "30s" | 否 |
server_write_timeout | duration | HTTP 服务器的写入超时时间。 | "30s" | 否 |
导出的字段
pyroscope.receive_http
不导出任何字段。
组件健康状态
如果配置无效,则 pyroscope.receive_http
将报告为不健康状态。
示例
此示例创建了一个 pyroscope.receive_http
组件,该组件启动一个监听 0.0.0.0
地址和端口 9999
的 HTTP 服务器。该服务器接收 profile 数据,并将其转发给多个 pyroscope.write
组件,这些组件将 profile 数据写入不同的 HTTP 端点。
// Receives profiles over HTTP
pyroscope.receive_http "default" {
http {
listen_address = "0.0.0.0"
listen_port = 9999
}
forward_to = [pyroscope.write.staging.receiver, pyroscope.write.production.receiver]
}
// Send profiles to a staging Pyroscope instance
pyroscope.write "staging" {
endpoint {
url = "http://pyroscope-staging:4040"
}
}
// Send profiles to a production Pyroscope instance
pyroscope.write "production" {
endpoint {
url = "http://pyroscope-production:4040"
}
}
注意
此示例演示了将 profile 数据转发到多个
pyroscope.write
组件。此配置会复制收到的 profile 数据,并将一份副本发送给每个配置的pyroscope.write
组件。
您还可以创建具有不同配置的多个 pyroscope.receive_http
组件,以便根据需要监听不同的地址或端口。这种灵活性使您能够设计出最适合您的基础设施和 profile 数据路由要求的设置。
兼容组件
pyroscope.receive_http
可以接受来自以下组件的参数
- 导出 Pyroscope
ProfilesReceiver
的组件
注意
连接某些组件可能不合理,或者组件可能需要进一步配置才能使连接正常工作。请参阅链接的文档了解更多详细信息。