graphite_data
`graphite_data` 指令配置 NGINX 以收集并发送有关请求的聚合指标到指定的 Graphite 后端。
An NGINX module for collecting stats into Graphite
·
httpserverlocationif in location
语法graphite_data name [params];
默认值none
上下文http, server, location, if in location
参数1-3
说明
graphite_data 指令是 Graphite NGINX 模块的重要组成部分,允许用户定义自定义指标,这些指标会被聚合并发送到 Graphite 服务器。通过在 NGINX 配置块中(在 http、server 或 location 上下文)使用该指令,管理员可以指定将被记录并上报的唯一指标名称。该指令的参数可以包含指标名称和参数的组合,用以微调收集哪些统计数据、如何聚合以及何时发送。
当调用 graphite_data 时,它会在指定的 NGINX 上下文中为定义的指标创建一个数据流。该指标随后会根据流量数据(如请求计数、响应时间及其他定义的参数)实时更新。参数会被解析并用于按 graphite_config 中定义的方式格式化指标名称,从而实现对 Graphite 服务器的结构化且一致的上报。数据通常按指定的间隔聚合并发送(默认每 60 秒)。此功能通过以非阻塞方式发送指标,特别适用于 NGINX 托管应用的实时监控和性能跟踪,同时确保对 Web 服务器本身的性能影响最小。
配置示例
http {
graphite_config prefix=playground server=127.0.0.1;
server {
location /foo/ {
graphite_data nginx.foo;
}
}
}⚠
确保 Graphite 服务器已正确配置并且可以从 NGINX 访问。
⚠
检查 graphite_config 中的前缀和指标命名格式是否与您的 Graphite 后端预期的输入相匹配。
⚠
请记住,指定过多的指标可能会由于内存和处理开销而导致性能下降。