跳到主要内容

内置指标

每个夜莺进程在 /metrics 上暴露的自身指标。

每个进程都在自己的 HTTP 端口上暴露 /metrics,Prometheus 格式:

curl http://n9e:17000/metrics

由 [HTTP] ExposeMetrics 控制,默认开着。

告警系统自己挂了是不会给你发告警的,所以这套指标该被你的监控系统抓走, 并配上规则——怎么配见监控夜莺自身。

先看哪几个​

按「出问题时最先暴露」排:

指标说明
n9e_alert_rule_eval_total / n9e_alert_rule_eval_error_total规则判定跑了多少次、错了多少次。判定停了这里最先看得出来
n9e_alert_rule_eval_duration_ms单次判定耗时。数据源变慢会先反映在这里
n9e_alert_alert_queue_size事件队列积压。持续增长说明下游消费不过来
n9e_alert_query_data_error_total查询数据源失败次数
n9e_center_http_request_duration_secondsWeb / API 的响应耗时
n9e_db_operation_latency_seconds元数据库的操作耗时

完整清单​

夜莺自己的指标共 55 条,都在每个进程的 /metrics 上([HTTP] ExposeMetrics 默认开)。

下面不含 Go runtime 和 process 那批——那是所有 Go 程序都有的,不是夜莺的自监控信息。

带 † 的 16 条是从源码里补的:带标签的指标在第一次被触发之前不会出现在 /metrics 里,所以一个刚起来的实例上查不到它们。这不是缺陷,配告警规则时按名字写就行。

n9e_alert_*​

指标类型含义
n9e_alert_alert_notify_error_total †counterNumber of send msg.
n9e_alert_alert_notify_total †counterNumber of send msg.
n9e_alert_alert_queue_sizegaugeThe size of alert queue.
n9e_alert_alerts_totalcounterTotal number alert events.
n9e_alert_eval_log_drop_totalcounterNumber of eval log records dropped (full write queue, or still oversized after full degradation).
n9e_alert_eval_log_query_reject_totalcounterNumber of eval log queries rejected by the concurrency gate.
n9e_alert_eval_query_series_countgaugeNumber of series retrieved from data source after query.
n9e_alert_heartbeat_error_count †counterNumber of heartbeat error.
n9e_alert_mute_total †counterNumber of mute.
n9e_alert_notify_record_queue_sizegaugeThe size of notify record queue.
n9e_alert_query_data_error_total †counterNumber of rule eval query data error.
n9e_alert_query_data_totalcounterNumber of rule eval query data.
n9e_alert_record_eval_duration_ms †gaugeDuration of record eval in milliseconds.
n9e_alert_record_eval_error_total †counterNumber of record eval errors, labeled by stage.
n9e_alert_record_eval_series_count †gaugeSeries count produced by the latest record eval; negative values encode error states.
n9e_alert_record_eval_total †counterNumber of record eval.
n9e_alert_rule_eval_duration_msgaugeDuration of rule eval in milliseconds.
n9e_alert_rule_eval_error_total †counterNumber of rule eval error.
n9e_alert_rule_eval_totalcounterNumber of rule eval.
n9e_alert_sub_event_total †counterNumber of sub event.
n9e_alert_var_filling_query_total †counterNumber of var filling query.

n9e_center_*​

指标类型含义
n9e_center_http_request_duration_secondshistogramHTTP request latencies in seconds.
n9e_center_redis_operation_latency_secondshistogramHistogram of latencies for Redis operations
n9e_center_uptimecounterHTTP service uptime.

n9e_cron_*​

指标类型含义
n9e_cron_durationgaugeCron method use duration, unit: ms.
n9e_cron_sync_numbergaugeCron sync number.

n9e_db_*​

指标类型含义
n9e_db_operation_latency_secondshistogramHistogram of latencies for DB operations
n9e_db_operation_totalcounterTotal number of DB operations
n9e_db_pool_idle_connectionsgaugeThe number of idle connections
n9e_db_pool_in_use_connectionsgaugeThe number of connections currently in use
n9e_db_pool_max_idle_closed_totalcounterThe total number of connections closed due to SetMaxIdleConns
n9e_db_pool_max_idle_time_closed_totalcounterThe total number of connections closed due to SetConnMaxIdleTime
n9e_db_pool_max_lifetime_closed_totalcounterThe total number of connections closed due to SetConnMaxLifetime
n9e_db_pool_max_open_connectionsgaugeMaximum number of open connections to the database
n9e_db_pool_open_connectionsgaugeThe number of established connections both in use and idle
n9e_db_pool_wait_count_totalcounterThe total number of connections waited for
n9e_db_pool_wait_duration_seconds_totalcounterThe total time blocked waiting for a new connection

n9e_pushgw_*​

指标类型含义
n9e_pushgw_drop_sample_totalcounterNumber of drop sample.
n9e_pushgw_forward_duration_secondshistogramForward samples to TSDB. latencies in seconds.
n9e_pushgw_http_request_duration_secondshistogramHTTP request latencies in seconds.
n9e_pushgw_proxy_forward_error_total †counterNumber of forward errors on /proxy/v1/write.
n9e_pushgw_proxy_forward_total †counterNumber of forwards performed by /proxy/v1/write.
n9e_pushgw_proxy_remote_write_body_too_large_totalcounterNumber of /proxy/v1/write requests rejected with 413 due to body size over limit.
n9e_pushgw_proxy_remote_write_inflightgaugeCurrent number of in-flight requests on /proxy/v1/write.
n9e_pushgw_proxy_remote_write_over_limit_totalcounterNumber of /proxy/v1/write requests rejected with 429 due to in-flight over limit.
n9e_pushgw_proxy_remote_write_totalcounterNumber of /proxy/v1/write requests received.
n9e_pushgw_push_queue_error_total †counterNumber of push queue error.
n9e_pushgw_push_queue_over_limit_error_totalcounterNumber of push queue over limit.
n9e_pushgw_redis_operation_latency_secondshistogramHistogram of latencies for Redis operations
n9e_pushgw_sample_queue_sizegaugeThe size of sample queue.
n9e_pushgw_sample_received_by_identcounterNumber of sample push by ident.
n9e_pushgw_samples_received_totalcounterTotal number samples received.
n9e_pushgw_write_error_total †counterNumber of write error.
n9e_pushgw_write_totalcounterNumber of write.

n9e_sandbox_*​

指标类型含义
n9e_sandbox_exec_activegaugeCurrently running sandbox executions.