@@ -9,9 +9,10 @@ import (
99 "time"
1010)
1111
12- // MetricSnapshot represents a parsed snapshot of all essential metrics
12+ // NodeExporterMetricSnapshot represents a parsed snapshot of node_exporter metrics
1313// This matches the admiral.metrics table schema (raw values, no percentages)
14- type MetricSnapshot struct {
14+ // Specifically designed for Prometheus node_exporter metrics only
15+ type NodeExporterMetricSnapshot struct {
1516 Timestamp time.Time `json:"timestamp"`
1617
1718 // CPU Metrics (seconds, raw values from counters)
@@ -72,10 +73,11 @@ type MetricSnapshot struct {
7273 UptimeSeconds int64 `json:"uptime_seconds"`
7374}
7475
75- // ParsePrometheusMetrics parses Prometheus text format and extracts essential metrics
76- // Returns a MetricSnapshot with raw counter values (no percentages calculated)
77- func ParsePrometheusMetrics (data []byte ) (* MetricSnapshot , error ) {
78- snapshot := & MetricSnapshot {
76+ // ParseNodeExporterMetrics parses Prometheus node_exporter text format and extracts essential metrics
77+ // Returns a NodeExporterMetricSnapshot with raw counter values (no percentages calculated)
78+ // This parser is specifically designed for node_exporter metrics only
79+ func ParseNodeExporterMetrics (data []byte ) (* NodeExporterMetricSnapshot , error ) {
80+ snapshot := & NodeExporterMetricSnapshot {
7981 Timestamp : time .Now ().UTC (),
8082 }
8183
@@ -155,7 +157,7 @@ type diskMetrics struct {
155157 ioTimeSeconds float64
156158}
157159
158- func parseLine (line string , snapshot * MetricSnapshot ,
160+ func parseLine (line string , snapshot * NodeExporterMetricSnapshot ,
159161 cpuIdle , cpuUser , cpuSystem , cpuIowait , cpuSteal map [string ]float64 ,
160162 networkDevices map [string ]* networkMetrics ,
161163 diskDevices map [string ]* diskMetrics ) error {
@@ -429,7 +431,7 @@ func isPhysicalNetwork(device string) bool {
429431 return true
430432}
431433
432- func selectPrimaryNetwork (snapshot * MetricSnapshot , devices map [string ]* networkMetrics ) {
434+ func selectPrimaryNetwork (snapshot * NodeExporterMetricSnapshot , devices map [string ]* networkMetrics ) {
433435 // Priority: eth0 > en0 > first available
434436 var primary * networkMetrics
435437 if devices ["eth0" ] != nil {
@@ -456,7 +458,7 @@ func selectPrimaryNetwork(snapshot *MetricSnapshot, devices map[string]*networkM
456458 }
457459}
458460
459- func selectPrimaryDisk (snapshot * MetricSnapshot , devices map [string ]* diskMetrics ) {
461+ func selectPrimaryDisk (snapshot * NodeExporterMetricSnapshot , devices map [string ]* diskMetrics ) {
460462 // Priority: vda > sda > nvme0n1 > first available
461463 var primary * diskMetrics
462464 if devices ["vda" ] != nil {
0 commit comments