菜单
文档breadcrumb arrow Grafana Alloybreadcrumb arrow 参考breadcrumb arrow 组件breadcrumb arrow pyroscopebreadcrumb arrow pyroscope.receive_http
公开预览 开源

pyroscope.receive_http

公开预览:这是一个公开预览组件。公开预览组件可能会发生重大更改,并可能被涵盖相同用例的等效功能取代。必须将 stability.level 标志设置为 public-preview 或更低才能使用该组件。

pyroscope.receive_http 通过 HTTP 接收 profile 数据,并将其转发到能够接收 profile 数据的 pyroscope.* 组件。

暴露的 HTTP API 与 Pyroscope 的 HTTP 摄取 APIpushv1.PusherService Connect API 兼容。这使得 pyroscope.receive_http 可以充当 Pyroscope profile 数据的代理,从而实现 profile 数据的灵活路由和分发。

用法

alloy
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_tolist(ProfilesReceiver)要将 profile 数据发送到的接收者列表。

您可以将以下块与 pyroscope.receive_http 一起使用

名称描述必需
http配置接收请求的 HTTP 服务器。

http

http 块用于配置 HTTP 服务器。

您可以使用以下参数配置 http 块。任何被省略的字段将采用其默认值。

名称类型描述默认值必需
conn_limitint最大同时 HTTP 连接数。默认值为 100。0
listen_addressstring服务器监听新连接的网络地址。默认接受所有传入连接。""
listen_portint服务器监听新连接的端口号。8080
server_idle_timeoutdurationHTTP 服务器的空闲超时时间。"120s"
server_read_timeoutdurationHTTP 服务器的读取超时时间。"30s"
server_write_timeoutdurationHTTP 服务器的写入超时时间。"30s"

导出的字段

pyroscope.receive_http 不导出任何字段。

组件健康状态

如果配置无效,则 pyroscope.receive_http 将报告为不健康状态。

示例

此示例创建了一个 pyroscope.receive_http 组件,该组件启动一个监听 0.0.0.0 地址和端口 9999 的 HTTP 服务器。该服务器接收 profile 数据,并将其转发给多个 pyroscope.write 组件,这些组件将 profile 数据写入不同的 HTTP 端点。

alloy
// 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 可以接受来自以下组件的参数

注意

连接某些组件可能不合理,或者组件可能需要进一步配置才能使连接正常工作。请参阅链接的文档了解更多详细信息。