@@ -449,7 +449,7 @@ collect_all_metrics() {
449449 fds=${fds// [[:space:]]/ } # strip whitespace from wc -l
450450 threads=$( awk ' /Threads/ {print $2}' " /proc/$pid /status" 2> /dev/null || echo " 0" )
451451
452- metrics+=" nftban_memory_rss_bytes $rss $timestamp \n"
452+ metrics+=" nftban_proc_rss_bytes $rss $timestamp \n"
453453 metrics+=" nftban_open_fds $fds $timestamp \n"
454454 metrics+=" nftban_threads $threads $timestamp \n"
455455
@@ -474,7 +474,7 @@ collect_all_metrics() {
474474 fi
475475 # Fallback: use thread count as approximation if goroutines not available
476476 [[ " $goroutines " == " 0" || -z " $goroutines " ]] && goroutines=$threads
477- metrics+=" nftban_goroutines $goroutines $timestamp \n"
477+ metrics+=" nftban_runtime_goroutines $goroutines $timestamp \n"
478478
479479 # --- Memory Leak Detection Metrics ---
480480 # Calculate memory growth rate (MB/hour) for leak detection
@@ -591,7 +591,7 @@ collect_all_metrics() {
591591 fi
592592 metrics+=" nftban_nftables_apply_errors_total $nft_apply_errors $timestamp \n"
593593
594- # nftban_nftables_rules_total - count rules in nftban table
594+ # nftban_nft_rules_total - count rules in nftban table
595595 local nft_rules_total=0
596596 local table_output
597597 table_output=$( nft list table ${NFTBAN_TABLE_IPV4} 2> /dev/null || echo " " )
@@ -600,7 +600,7 @@ collect_all_metrics() {
600600 nft_rules_total=$( echo " $table_output " | grep -cE ' ^\s+(accept|drop|reject|jump|goto|counter|log|limit|ct )' 2> /dev/null | tr -d ' [:space:]' ) || true
601601 [[ -z " $nft_rules_total " || ! " $nft_rules_total " =~ ^[0-9]+$ ]] && nft_rules_total=0
602602 fi
603- metrics+=" nftban_nftables_rules_total $nft_rules_total $timestamp \n"
603+ metrics+=" nftban_nft_rules_total $nft_rules_total $timestamp \n"
604604
605605 # nftban_nftables_sets_total - count sets in nftban table
606606 local nft_sets_total=0
@@ -856,17 +856,20 @@ collect_all_metrics() {
856856 net_score=$( jq -r ' .net_score // 0' " ${NFTBAN_RUN_DIR} /watchdog.status" 2> /dev/null || echo " 0" )
857857 watchdog_mode=$( jq -r ' .mode // "NORMAL"' " ${NFTBAN_RUN_DIR} /watchdog.status" 2> /dev/null || echo " NORMAL" )
858858
859- metrics+=" nftban_watchdog_cpu_score $cpu_score $timestamp \n"
860- metrics+=" nftban_watchdog_mem_score $mem_score $timestamp \n"
861- metrics+=" nftban_watchdog_io_score $io_score $timestamp \n"
862- metrics+=" nftban_watchdog_net_score $net_score $timestamp \n"
863- # Mode as numeric: 0=NORMAL, 1=DEGRADED, 2=SURVIVAL
864- local mode_num =0
859+ metrics+=" nftban_pressure_score{dim= \" cpu \" } $cpu_score $timestamp \n"
860+ metrics+=" nftban_pressure_score{dim= \" mem \" } $mem_score $timestamp \n"
861+ metrics+=" nftban_pressure_score{dim= \" io \" } $io_score $timestamp \n"
862+ metrics+=" nftban_pressure_score{dim= \" net \" } $net_score $timestamp \n"
863+ # Mode as one-hot vector matching daemon nftban_operating_mode{mode=X}
864+ local mode_normal=0 mode_degraded=0 mode_survival =0
865865 case " $watchdog_mode " in
866- DEGRADED) mode_num=1 ;;
867- SURVIVAL) mode_num=2 ;;
866+ NORMAL) mode_normal=1 ;;
867+ DEGRADED) mode_degraded=1 ;;
868+ SURVIVAL) mode_survival=1 ;;
868869 esac
869- metrics+=" nftban_watchdog_mode $mode_num $timestamp \n"
870+ metrics+=" nftban_operating_mode{mode=\" normal\" } $mode_normal $timestamp \n"
871+ metrics+=" nftban_operating_mode{mode=\" degraded\" } $mode_degraded $timestamp \n"
872+ metrics+=" nftban_operating_mode{mode=\" survival\" } $mode_survival $timestamp \n"
870873 fi
871874 metrics+=" nftban_watchdog_up 1 $timestamp \n"
872875 else
@@ -908,7 +911,7 @@ collect_all_metrics() {
908911 metrics+=" nftban_daemon_uptime_seconds $d_uptime $timestamp \n"
909912 metrics+=" nftban_daemon_memory_heap_mb $d_heap $timestamp \n"
910913 metrics+=" nftban_daemon_memory_sys_mb $d_sys $timestamp \n"
911- metrics+=" nftban_daemon_goroutines $d_goroutines $timestamp \n"
914+ metrics+=" nftban_runtime_goroutines $d_goroutines $timestamp \n"
912915 metrics+=" nftban_daemon_gc_cycles_total $d_gc_cycles $timestamp \n"
913916 metrics+=" nftban_daemon_gc_pause_ms $d_gc_pause $timestamp \n"
914917
@@ -1266,7 +1269,7 @@ collect_all_metrics() {
12661269 if [[ $conntrack_max -gt 0 ]]; then
12671270 conntrack_utilization=$( awk -v e=" $conntrack_entries " -v m=" $conntrack_max " ' BEGIN {printf "%.2f", (e/m)*100}' )
12681271 fi
1269- metrics+=" nftban_conntrack_entries $conntrack_entries $timestamp \n"
1272+ metrics+=" nftban_conntrack_used $conntrack_entries $timestamp \n"
12701273 metrics+=" nftban_conntrack_max $conntrack_max $timestamp \n"
12711274 metrics+=" nftban_conntrack_utilization $conntrack_utilization $timestamp \n"
12721275 fi
0 commit comments