菜单
开源 RSS

Grafana Alloy HTTP 端点

Grafana Alloy 提供多个默认 HTTP 端点,无论您配置了哪些组件,这些端点都默认可用。您可以使用这些 HTTP 端点来监控、检查健康状况以及排查 Alloy 的问题。

公开这些端点的 HTTP 服务器可通过 http 块--server. 命令行参数进行配置。例如,如果您将 --server.http.listen-addr 命令行参数设置为 127.0.0.1:12345,您可以查询 127.0.0.1:12345/metrics 端点来查看 Alloy 的内部指标。

/metrics

/metrics 端点以 Prometheus exposition 格式返回 Alloy 的内部指标。

/-/ready

Alloy 实例在加载其初始配置后即视为就绪。如果实例就绪,/-/ready 端点将返回 HTTP 200 OK 和消息 Alloy is ready.。否则,如果实例未就绪,/-/ready 端点将返回 HTTP 503 Service Unavailable 和消息 Alloy is not ready.

/-/healthy

当所有 Alloy 组件正常工作时,所有组件都被视为健康。如果所有组件都健康,/-/healthy 端点将返回 HTTP 200 OK 和消息 All Alloy components are healthy.。否则,如果任何组件工作不正常,/-/healthy 端点将返回 HTTP 500 Internal Server Error 和错误消息。您也可以通过 Alloy UI 监控组件健康状况。

shell
$ curl localhost:12345/-/healthy
All Alloy components are healthy.
shell
$ curl localhost:12345/-/healthy
unhealthy components: math.add

注意

/-/healthy 端点不适合用作 Kubernetes 存活探针(liveness probe)

报告不健康的 Alloy 实例不一定需要重启。例如,某个组件可能因配置无效或外部资源不可用而不健康。在这种情况下,重启 Alloy 无法解决问题。重启反而可能导致情况更糟,因为它会中断健康 pipeline 中的遥测数据流。

/-/reload

/-/reload 端点用于重新加载 Alloy 配置文件。如果配置文件无法重新加载,/-/reload 端点将返回 HTTP 400 Bad Request 和错误消息。

shell
$ curl localhost:12345/-/reload
config reloaded
shell
$ curl localhost:12345/-/reload
error during the initial load: /Users/user1/Desktop/git.alloy:13:1: Failed to build component: loading custom component controller: custom component config not found in the registry, namespace: "math", componentName: "add"

/-/support

/-/support 端点返回一个支持包,其中包含关于您的 Alloy 实例的信息。您可以使用这些信息作为排查问题时的基准。

/debug/pprof

/debug/pprof 端点返回 pprof Go性能分析数据,您可以使用它来可视化和分析性能分析数据。