启用 Prometheus 指标(Enable Prometheus metrics)#
为了收集和展示指标,n8n 使用 prom-client 库。
🌐 To collect and expose metrics, n8n uses the prom-client library.
/metrics 端点默认是禁用的,但可以通过 N8N_METRICS 环境变量启用它。
🌐 The /metrics endpoint is disabled by default, but it's possible to enable it using the N8N_METRICS environment variable.
1 | |
请参阅相应的环境变量(N8N_METRICS_INCLUDE_*)以配置应公开哪些指标和标签。
🌐 Refer to the respective Environment Variables (N8N_METRICS_INCLUDE_*) for configuring which metrics and labels should get exposed.
main 和 worker 实例都能够暴露指标。
🌐 Both main and worker instances are able to expose metrics.
队列指标(Queue metrics)#
要启用队列指标,请将 N8N_METRICS_INCLUDE_QUEUE_METRICS 环境变量设置为 true。你可以使用 N8N_METRICS_QUEUE_METRICS_INTERVAL 调整刷新频率。
🌐 To enable queue metrics, set the N8N_METRICS_INCLUDE_QUEUE_METRICS env var to true. You can adjust the refresh rate with N8N_METRICS_QUEUE_METRICS_INTERVAL.
n8n 从 Bull 收集这些指标并在主实例上显示。在多主节点设置中,当聚合查询时,您可以使用 instance_role_leader 指标来识别主节点,主节点设置为 1,其他节点设置为 0。
🌐 n8n gathers these metrics from Bull and exposes them on the main instances. On multi-main setups, when aggregating queries, you can identify the leader using the instance_role_leader gauge, set to 1 for the leader main and 0 otherwise.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |