From 60baf0243da8354066824b9347801571d99315fe Mon Sep 17 00:00:00 2001 From: Stefano Torresi Date: Thu, 14 Nov 2019 12:42:44 +0100 Subject: [PATCH 1/2] make the resource and node name/id labels match across all the metrics that have it --- pacemaker_metrics.go | 6 +++--- test/pacemaker.metrics | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pacemaker_metrics.go b/pacemaker_metrics.go index a0dcd16..c421081 100644 --- a/pacemaker_metrics.go +++ b/pacemaker_metrics.go @@ -89,9 +89,9 @@ var ( pacemakerMetrics = metricDescriptors{ // the map key will function as an identifier of the metric throughout the rest of the code; // it is arbitrary, but by convention we use the actual metric name - "nodes": NewMetricDesc("pacemaker", "nodes", "The nodes in the cluster; one line per name, per status", []string{"name", "type", "status"}), + "nodes": NewMetricDesc("pacemaker", "nodes", "The nodes in the cluster; one line per name, per status", []string{"node", "type", "status"}), "nodes_total": NewMetricDesc("pacemaker", "nodes_total", "Total number of nodes in the cluster", nil), - "resources": NewMetricDesc("pacemaker", "resources", "The resources in the cluster; one line per id, per status", []string{"node", "id", "role", "managed", "status"}), + "resources": NewMetricDesc("pacemaker", "resources", "The resources in the cluster; one line per id, per status", []string{"node", "resource", "role", "managed", "status"}), "resources_total": NewMetricDesc("pacemaker", "resources_total", "Total number of resources in the cluster", nil), "stonith_enabled": NewMetricDesc("pacemaker", "stonith_enabled", "Whether or not stonith is enabled", nil), "fail_count": NewMetricDesc("pacemaker", "fail_count", "The Fail count number per node and resource id", []string{"node", "resource"}), @@ -221,7 +221,7 @@ func (c *pacemakerCollector) recordResourcesMetrics(node node, ch chan<- prometh "resources", float64(1), node.Name, - strings.ToLower(resource.ID), + resource.ID, strings.ToLower(resource.Role), strconv.FormatBool(resource.Managed), resourceStatus) diff --git a/test/pacemaker.metrics b/test/pacemaker.metrics index f765e98..c5702a6 100644 --- a/test/pacemaker.metrics +++ b/test/pacemaker.metrics @@ -24,22 +24,22 @@ ha_cluster_pacemaker_migration_threshold{node="hana02",resource="rsc_SAPHanaTopo ha_cluster_pacemaker_migration_threshold{node="hana02",resource="rsc_SAPHana_PRD_HDB00"} 50 1234 # HELP ha_cluster_pacemaker_nodes The nodes in the cluster; one line per name, per status # TYPE ha_cluster_pacemaker_nodes gauge -ha_cluster_pacemaker_nodes{name="hana01",status="dc",type="member"} 1 1234 -ha_cluster_pacemaker_nodes{name="hana01",status="expected_up",type="member"} 1 1234 -ha_cluster_pacemaker_nodes{name="hana01",status="online",type="member"} 1 1234 -ha_cluster_pacemaker_nodes{name="hana02",status="expected_up",type="member"} 1 1234 -ha_cluster_pacemaker_nodes{name="hana02",status="online",type="member"} 1 1234 +ha_cluster_pacemaker_nodes{node="hana01",status="dc",type="member"} 1 1234 +ha_cluster_pacemaker_nodes{node="hana01",status="expected_up",type="member"} 1 1234 +ha_cluster_pacemaker_nodes{node="hana01",status="online",type="member"} 1 1234 +ha_cluster_pacemaker_nodes{node="hana02",status="expected_up",type="member"} 1 1234 +ha_cluster_pacemaker_nodes{node="hana02",status="online",type="member"} 1 1234 # HELP ha_cluster_pacemaker_nodes_total Total number of nodes in the cluster # TYPE ha_cluster_pacemaker_nodes_total gauge ha_cluster_pacemaker_nodes_total 2 1234 # HELP ha_cluster_pacemaker_resources The resources in the cluster; one line per id, per status # TYPE ha_cluster_pacemaker_resources gauge -ha_cluster_pacemaker_resources{id="rsc_ip_prd_hdb00",managed="true",node="hana01",role="started",status="active"} 1 1234 -ha_cluster_pacemaker_resources{id="rsc_saphana_prd_hdb00",managed="true",node="hana01",role="master",status="active"} 1 1234 -ha_cluster_pacemaker_resources{id="rsc_saphana_prd_hdb00",managed="true",node="hana02",role="slave",status="active"} 1 1234 -ha_cluster_pacemaker_resources{id="rsc_saphanatopology_prd_hdb00",managed="true",node="hana01",role="started",status="active"} 1 1234 -ha_cluster_pacemaker_resources{id="rsc_saphanatopology_prd_hdb00",managed="true",node="hana02",role="started",status="active"} 1 1234 -ha_cluster_pacemaker_resources{id="stonith-sbd",managed="true",node="hana01",role="started",status="active"} 1 1234 +ha_cluster_pacemaker_resources{managed="true",node="hana01",resource="rsc_ip_PRD_HDB00",role="started",status="active"} 1 1234 +ha_cluster_pacemaker_resources{managed="true",node="hana01",resource="rsc_SAPHana_PRD_HDB00",role="master",status="active"} 1 1234 +ha_cluster_pacemaker_resources{managed="true",node="hana01",resource="rsc_SAPHanaTopology_PRD_HDB00",role="started",status="active"} 1 1234 +ha_cluster_pacemaker_resources{managed="true",node="hana01",resource="stonith-sbd",role="started",status="active"} 1 1234 +ha_cluster_pacemaker_resources{managed="true",node="hana02",resource="rsc_SAPHana_PRD_HDB00",role="slave",status="active"} 1 1234 +ha_cluster_pacemaker_resources{managed="true",node="hana02",resource="rsc_SAPHanaTopology_PRD_HDB00",role="started",status="active"} 1 1234 # HELP ha_cluster_pacemaker_resources_total Total number of resources in the cluster # TYPE ha_cluster_pacemaker_resources_total gauge ha_cluster_pacemaker_resources_total 6 1234 From 251c35af79147368bcc59ef37164d191c36aa58e Mon Sep 17 00:00:00 2001 From: Stefano Torresi Date: Thu, 14 Nov 2019 13:10:03 +0100 Subject: [PATCH 2/2] make drbd resource label usage consistent --- drbd_metrics.go | 2 +- test/drbd.metrics | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drbd_metrics.go b/drbd_metrics.go index 9a6de04..06ab5d9 100644 --- a/drbd_metrics.go +++ b/drbd_metrics.go @@ -34,7 +34,7 @@ var ( drbdMetrics = metricDescriptors{ // the map key will function as an identifier of the metric throughout the rest of the code; // it is arbitrary, but by convention we use the actual metric name - "resources": NewMetricDesc("drbd", "resources", "The DRBD resources; 1 line per name, per volume", []string{"name", "role", "volume", "disk_state"}), + "resources": NewMetricDesc("drbd", "resources", "The DRBD resources; 1 line per name, per volume", []string{"resource", "role", "volume", "disk_state"}), "connections": NewMetricDesc("drbd", "connections", "The DRBD resource connections; 1 line per per resource, per peer_node_id", []string{"resource", "peer_node_id", "peer_role", "volume", "peer_disk_state"}), "connections_sync": NewMetricDesc("drbd", "connections_sync", "The in sync percentage value for DRBD resource connections", []string{"resource", "peer_node_id", "volume"}), } diff --git a/test/drbd.metrics b/test/drbd.metrics index 6b58272..f08941a 100644 --- a/test/drbd.metrics +++ b/test/drbd.metrics @@ -8,5 +8,5 @@ ha_cluster_drbd_connections_sync{peer_node_id="1",resource="1-single-0",volume=" ha_cluster_drbd_connections_sync{peer_node_id="1",resource="1-single-1",volume="0"} 100 1234 # HELP ha_cluster_drbd_resources The DRBD resources; 1 line per name, per volume # TYPE ha_cluster_drbd_resources gauge -ha_cluster_drbd_resources{disk_state="uptodate",name="1-single-0",role="Secondary",volume="0"} 1 1234 -ha_cluster_drbd_resources{disk_state="uptodate",name="1-single-1",role="Secondary",volume="0"} 1 1234 +ha_cluster_drbd_resources{disk_state="uptodate",resource="1-single-0",role="Secondary",volume="0"} 1 1234 +ha_cluster_drbd_resources{disk_state="uptodate",resource="1-single-1",role="Secondary",volume="0"} 1 1234