diff --git a/main.go b/main.go index 4dc4e81..7d389a6 100644 --- a/main.go +++ b/main.go @@ -37,6 +37,7 @@ func main() { r := prometheus.NewRegistry() r.MustRegister(metrics.InterfaceStat) r.MustRegister(metrics.CallCount) + r.MustRegister(metrics.HeapInfo) http.Handle("/metrics", promhttp.HandlerFor(r, promhttp.HandlerOpts{})) diff --git a/metrics/metrics.go b/metrics/metrics.go index cbef5ad..6e37c08 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -47,7 +47,13 @@ func queryTelemetry(conn net.Conn, log *logrus.Logger, command string, response func Update(conn net.Conn, hostname string, log *logrus.Logger) { var dpserviceHeapInfo DpServiceHeapInfo - queryTelemetry(conn, log, "/eal/heap_info", &dpserviceHeapInfo) + queryTelemetry(conn, log, "/eal/heap_info,0", &dpserviceHeapInfo) + for key, value := range dpserviceHeapInfo.Value { + // Only export metrics of type float64 (/eal/heap_info contains also some string values) + if v, ok := value.(float64); ok { + HeapInfo.With(prometheus.Labels{"node_name": hostname, "info": key}).Set(v) + } + } var ethdevList EthdevList queryTelemetry(conn, log, "/ethdev/list", ðdevList) diff --git a/metrics/types.go b/metrics/types.go index ea402b1..ba65315 100644 --- a/metrics/types.go +++ b/metrics/types.go @@ -64,5 +64,5 @@ type DpServiceGraphCallCount struct { } type DpServiceHeapInfo struct { - Value map[string]int `json:"/eal/heap_info"` + Value map[string]any `json:"/eal/heap_info"` }