add rtr report metrics

This commit is contained in:
2026-06-30 17:40:28 +08:00
parent d5270308d6
commit a67640db83
4 changed files with 1561 additions and 8 deletions

View File

@@ -115,6 +115,11 @@ METRICS_LISTEN=0.0.0.0:9556
METRICS_POLL_SECS=5
METRICS_INSTANCE=remote231-24h
# 可选:显式开启外部 RTR report JSON 指标采集。
# 为空或未设置时不采集;设置后应指向包含
# rtr-source-*.json / rtr-runtime-*.json / rtr-clients-*.json 的目录。
RPKI_METRICS_RTR_REPORT_DIR=
# 是否启动 query service。启动后默认只索引启动后新完成的 run,避免补历史 run 影响 RP 性能。
START_QUERY_SERVICE=0

View File

@@ -31,6 +31,7 @@ STOP_METRICS_SERVICE_ON_EXIT="${STOP_METRICS_SERVICE_ON_EXIT:-0}"
METRICS_LISTEN="${METRICS_LISTEN:-0.0.0.0:9556}"
METRICS_POLL_SECS="${METRICS_POLL_SECS:-5}"
METRICS_INSTANCE="${METRICS_INSTANCE:-remote231-24h}"
RPKI_METRICS_RTR_REPORT_DIR="${RPKI_METRICS_RTR_REPORT_DIR:-}"
START_QUERY_SERVICE="${START_QUERY_SERVICE:-0}"
STOP_QUERY_SERVICE_ON_EXIT="${STOP_QUERY_SERVICE_ON_EXIT:-0}"
QUERY_LISTEN="${QUERY_LISTEN:-0.0.0.0:9560}"
@@ -145,12 +146,17 @@ main() {
free -h > "$LOG_ROOT/24h-free-before.txt" 2>&1 || true
if is_true "$START_METRICS_SERVICE"; then
"$BIN_DIR/rpki_artifact_metrics" \
--run-root "$RUN_ROOT" \
--listen "$METRICS_LISTEN" \
--poll-secs "$METRICS_POLL_SECS" \
--instance "$METRICS_INSTANCE" \
> "$LOG_ROOT/metrics.stdout" 2> "$LOG_ROOT/metrics.stderr" &
metrics_env=()
if [[ -n "$RPKI_METRICS_RTR_REPORT_DIR" ]]; then
metrics_env+=(RPKI_METRICS_RTR_REPORT_DIR="$RPKI_METRICS_RTR_REPORT_DIR")
fi
env "${metrics_env[@]}" \
"$BIN_DIR/rpki_artifact_metrics" \
--run-root "$RUN_ROOT" \
--listen "$METRICS_LISTEN" \
--poll-secs "$METRICS_POLL_SECS" \
--instance "$METRICS_INSTANCE" \
> "$LOG_ROOT/metrics.stdout" 2> "$LOG_ROOT/metrics.stderr" &
METRICS_PID="$!"
echo "$METRICS_PID" > "$LOG_ROOT/metrics.pid"
fi