跳至内容

启用Prometheus指标#

为了收集和暴露指标,n8n使用prom-client库。

默认情况下,/metrics端点是被禁用的,但可以通过设置N8N_METRICS环境变量来启用它。

1
export N8N_METRICS=true

请参考相应的环境变量 (N8N_METRICS_INCLUDE_*) 来配置需要暴露的指标和标签。

无论是 main 还是 worker 实例都能暴露指标。

队列指标#

要启用队列指标,请将环境变量N8N_METRICS_INCLUDE_QUEUE_METRICS设置为true。您可以使用N8N_METRICS_QUEUE_METRICS_INTERVAL调整刷新频率。

队列指标仅在单主模式下的main实例中可用。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# HELP n8n_scaling_mode_queue_jobs_active Current number of jobs being processed across all workers in scaling mode.
# TYPE n8n_scaling_mode_queue_jobs_active gauge
n8n_scaling_mode_queue_jobs_active 0

# HELP n8n_scaling_mode_queue_jobs_completed Total number of jobs completed across all workers in scaling mode since instance start.
# TYPE n8n_scaling_mode_queue_jobs_completed counter
n8n_scaling_mode_queue_jobs_completed 0

# HELP n8n_scaling_mode_queue_jobs_failed Total number of jobs failed across all workers in scaling mode since instance start.
# TYPE n8n_scaling_mode_queue_jobs_failed counter
n8n_scaling_mode_queue_jobs_failed 0

# HELP n8n_scaling_mode_queue_jobs_waiting Current number of enqueued jobs waiting for pickup in scaling mode.
# TYPE n8n_scaling_mode_queue_jobs_waiting gauge
n8n_scaling_mode_queue_jobs_waiting 0
优云智算