From ae62104204e8f5b2fd6216997d43973a1db5ecb7 Mon Sep 17 00:00:00 2001 From: Marvin Date: Sat, 21 Mar 2020 12:39:37 -0500 Subject: [PATCH] refactor listallnodes; added new metric (#13) * refactor listallnodes to add more labels; added new metric for node total memory in gb --- pkg/prom/collector.go | 29 +++++++++++++++++++++++++++++ pkg/prom/metrics.go | 12 ++++++++++-- pkg/solidfire/types.go | 10 +++++----- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/pkg/prom/collector.go b/pkg/prom/collector.go index f7ba293..9b71ec1 100644 --- a/pkg/prom/collector.go +++ b/pkg/prom/collector.go @@ -199,6 +199,35 @@ func (c *solidfireCollector) Collect(ch chan<- prometheus.Metric) { strconv.Itoa(node.NodeID), node.Name, node.ChassisName, + strconv.Itoa(node.AssociatedFServiceID), + strconv.Itoa(node.AssociatedMasterServiceID), + node.PlatformInfo.ChassisType, + node.PlatformInfo.CPUModel, + node.PlatformInfo.NodeType, + node.PlatformInfo.PlatformConfigVersion, + node.Sip, + node.Sipi, + node.SoftwareVersion, + node.UUID, + ) + + ch <- prometheus.MustNewConstMetric( + MetricDescriptions.NodeMemory, + prometheus.CounterValue, + node.PlatformInfo.NodeMemoryGB, + strconv.Itoa(node.NodeID), + node.Name, + node.ChassisName, + strconv.Itoa(node.AssociatedFServiceID), + strconv.Itoa(node.AssociatedMasterServiceID), + node.PlatformInfo.ChassisType, + node.PlatformInfo.CPUModel, + node.PlatformInfo.NodeType, + node.PlatformInfo.PlatformConfigVersion, + node.Sip, + node.Sipi, + node.SoftwareVersion, + node.UUID, ) } diff --git a/pkg/prom/metrics.go b/pkg/prom/metrics.go index 54aadbb..a5ab3bb 100644 --- a/pkg/prom/metrics.go +++ b/pkg/prom/metrics.go @@ -95,7 +95,8 @@ type Descriptions struct { VolumeQoSWriteBlockSizes *prometheus.Desc // ListAllNodes - Node *prometheus.Desc + Node *prometheus.Desc + NodeMemory *prometheus.Desc // GetClusterStats ClusterStatsActualIOPS *prometheus.Desc @@ -653,7 +654,14 @@ func NewMetricDescriptions(namespace string) *Descriptions { d.Node = prometheus.NewDesc( prometheus.BuildFQName(namespace, "", "node_name"), "Cluster node name", - []string{"node_id", "node_name", "chassis_name"}, + []string{"node_id", "node_name", "chassis_name", "associated_fservice_id", "associated_master_service_id", "chassis_type", "cpu_model", "node_type", "platform_config_version", "sip", "sipi", "software_version", "uuid"}, + nil, + ) + + d.NodeMemory = prometheus.NewDesc( + prometheus.BuildFQName(namespace, "", "node_total_memory_gb"), + "Cluster node total memory in GB", + []string{"node_id", "node_name", "chassis_name", "associated_fservice_id", "associated_master_service_id", "chassis_type", "cpu_model", "node_type", "platform_config_version", "sip", "sipi", "software_version", "uuid"}, nil, ) diff --git a/pkg/solidfire/types.go b/pkg/solidfire/types.go index 8ec86f4..9028b22 100644 --- a/pkg/solidfire/types.go +++ b/pkg/solidfire/types.go @@ -325,11 +325,11 @@ type ListAllNodesResponse struct { NodeID int `json:"nodeID"` NodeSlot string `json:"nodeSlot"` PlatformInfo struct { - ChassisType string `json:"chassisType"` - CPUModel string `json:"cpuModel"` - NodeMemoryGB int `json:"nodeMemoryGB"` - NodeType string `json:"nodeType"` - PlatformConfigVersion string `json:"platformConfigVersion"` + ChassisType string `json:"chassisType"` + CPUModel string `json:"cpuModel"` + NodeMemoryGB float64 `json:"nodeMemoryGB"` + NodeType string `json:"nodeType"` + PlatformConfigVersion string `json:"platformConfigVersion"` } `json:"platformInfo"` Sip string `json:"sip"` Sipi string `json:"sipi"`