Skip to content

Commit

Permalink
Introduce configured_metrics_total (node and res)
Browse files Browse the repository at this point in the history
  • Loading branch information
MalloZup committed Sep 18, 2019
1 parent 36d8cb6 commit 20d1e8a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ type resource struct {
}

var (
clusterNodesConf = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "cluster_nodes_configured_total",
Help: "Number of nodes configured in ha cluster",
})

clusterResourcesConf = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "cluster_resources_configured_total",
Help: "Number of total configured resources in ha cluster",
})

// metrics with labels. (prefer these always as guideline)
clusterNodes = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Expand All @@ -85,6 +95,8 @@ var (
func initMetrics() {
prometheus.MustRegister(clusterNodes)
prometheus.MustRegister(nodeResources)
prometheus.MustRegister(clusterResourcesConf)
prometheus.MustRegister(clusterNodesConf)
}

func resetMetrics() {
Expand Down Expand Up @@ -152,6 +164,9 @@ func main() {
log.Panic(err)
}

clusterResourcesConf.Set(float64(status.Summary.Resources.Number))
clusterNodesConf.Set(float64(status.Summary.Nodes.Number))

// set node metrics
// cluster_nodes{node="dma-dog-hana01" type="master"} 1
for _, nod := range status.Nodes.Node {
Expand Down Expand Up @@ -195,8 +210,8 @@ func main() {

// parse node status
// this produce a metric like:
// cluster_resources{node="dma-dog-hana01" resource_name="RA1" type="active", managed="true" role="master"} 1
// cluster_resources{node="dma-dog-hana01" resource_name="RA1" type="failed" managed="false" role="master"} 1
// cluster_node_resources{managed="false",node="dma-dog-hana01",resource_name="rsc_saphanatopology_prd_hdb00",role="started",status="active"} 1
// cluster_node_resources{managed="true",node="dma-dog-hana01",resource_name="rsc_ip_prd_hdb00",role="started",status="active"} 1
for _, nod := range status.Nodes.Node {
for _, rsc := range nod.Resources {
if rsc.Active {
Expand Down

0 comments on commit 20d1e8a

Please sign in to comment.