Skip to content

Commit e617c0c

Browse files
committed
Allow prometheus collector to continue running even when qmgr down (#67)
* Report qmgr_status metric in such a situation * Updated "QMgr Status" sample dashboard to report both that metric and the new cluster status metric Update influxdb collector to use V2 APIs (#76) * New sample dashboard using some very basic Flux queries
1 parent c3b5aab commit e617c0c

File tree

17 files changed

+1835
-102
lines changed

17 files changed

+1835
-102
lines changed

cmd/mq_aws/exporter.go

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package main
22

33
/*
4-
Copyright (c) IBM Corporation 2016
4+
Copyright (c) IBM Corporation 2016,2021
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.
@@ -118,40 +118,54 @@ func Collect() error {
118118
log.Debugf("Skipping poll for object status")
119119
}
120120

121+
pollError := err
121122
if pollStatus {
122123
if config.cf.CC.UseStatus {
123124
err := mqmetric.CollectChannelStatus(config.cf.MonitoredChannels)
124125
if err != nil {
125126
log.Errorf("Error collecting channel status: %v", err)
127+
pollError = err
126128
} else {
127129
log.Debugf("Collected all channel status")
128130
}
129131

130132
err = mqmetric.CollectTopicStatus(config.cf.MonitoredTopics)
131133
if err != nil {
132134
log.Errorf("Error collecting topic status: %v", err)
135+
pollError = err
133136
} else {
134137
log.Debugf("Collected all topic status")
135138
}
136139

137140
err = mqmetric.CollectSubStatus(config.cf.MonitoredSubscriptions)
138141
if err != nil {
139142
log.Errorf("Error collecting subscription status: %v", err)
143+
pollError = err
140144
} else {
141145
log.Debugf("Collected all subscription status")
142146
}
143147

144148
err = mqmetric.CollectQueueStatus(config.cf.MonitoredQueues)
145149
if err != nil {
146150
log.Errorf("Error collecting queue status: %v", err)
151+
pollError = err
147152
} else {
148153
log.Debugf("Collected all queue status")
149154
}
155+
156+
err = mqmetric.CollectClusterStatus()
157+
if err != nil {
158+
log.Errorf("Error collecting cluster status: %v", err)
159+
pollError = err
160+
} else {
161+
log.Debugf("Collected all cluster status")
162+
}
150163
}
151164

152165
err = mqmetric.CollectQueueManagerStatus()
153166
if err != nil {
154167
log.Errorf("Error collecting queue manager status: %v", err)
168+
pollError = err
155169
} else {
156170
log.Debugf("Collected all queue manager status")
157171
}
@@ -160,10 +174,16 @@ func Collect() error {
160174
err = mqmetric.CollectUsageStatus()
161175
if err != nil {
162176
log.Errorf("Error collecting bufferpool/pageset status: %v", err)
177+
pollError = err
163178
} else {
164179
log.Debugf("Collected all buffer pool/pageset status")
165180
}
166181
}
182+
err = pollError
183+
}
184+
185+
if err != nil {
186+
log.Fatalf("Error collecting status: %v", err)
167187
}
168188

169189
thisDiscovery := time.Now()
@@ -375,6 +395,38 @@ func Collect() error {
375395
}
376396
}
377397

398+
series = "cluster"
399+
for _, attr := range mqmetric.GetObjectStatus("", mqmetric.OT_CLUSTER).Attributes {
400+
for key, value := range attr.Values {
401+
if value.IsInt64 {
402+
403+
qMgrName := strings.TrimSpace(config.cf.QMgrName)
404+
clusterName := mqmetric.GetObjectStatus("", mqmetric.OT_CLUSTER).Attributes[mqmetric.ATTR_CLUSTER_NAME].Values[key].ValueString
405+
qmType := mqmetric.GetObjectStatus("", mqmetric.OT_CLUSTER).Attributes[mqmetric.ATTR_CLUSTER_QMTYPE].Values[key].ValueInt64
406+
407+
qmTypeString := "PARTIAL"
408+
if qmType == int64(ibmmq.MQQMT_REPOSITORY) {
409+
qmTypeString = "FULL"
410+
}
411+
tags := map[string]string{
412+
"qmgr": qMgrName,
413+
"platform": platformString,
414+
"cluster": clusterName,
415+
"qmtype": qmTypeString,
416+
}
417+
418+
f := mqmetric.ClusterNormalise(attr, value.ValueInt64)
419+
420+
pt, _ := newPoint(series+"."+attr.MetricName, t, float64(f), tags)
421+
422+
bp.addPoint(pt)
423+
bp = c.Flush(bp)
424+
425+
log.Debugf("Adding cluster point %v", pt)
426+
}
427+
}
428+
}
429+
378430
series = "qmgr"
379431
for _, attr := range mqmetric.QueueManagerStatus.Attributes {
380432
for _, value := range attr.Values {

cmd/mq_aws/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func main() {
115115
mqmetric.SubInitAttributes()
116116
mqmetric.QueueManagerInitAttributes()
117117
mqmetric.UsageInitAttributes()
118+
mqmetric.ClusterInitAttributes()
118119
}
119120

120121
// Go into main loop for sending data to database

cmd/mq_coll/exporter.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,36 +86,49 @@ func Collect() error {
8686
}
8787
// If there has been sufficient interval since the last explicit poll for
8888
// status, then do that collection too
89+
pollError := err
8990
if pollStatus {
9091
if config.cf.CC.UseStatus {
9192
err := mqmetric.CollectQueueManagerStatus()
9293
if err != nil {
9394
log.Errorf("Error collecting queue manager status: %v", err)
95+
pollError = err
9496
} else {
9597
log.Debugf("Collected all queue manager status")
9698
}
9799
err = mqmetric.CollectChannelStatus(config.cf.MonitoredChannels)
98100
if err != nil {
99101
log.Errorf("Error collecting channel status: %v", err)
102+
pollError = err
100103
} else {
101104
log.Debugf("Collected all channel status")
102105
}
103106
err = mqmetric.CollectTopicStatus(config.cf.MonitoredTopics)
104107
if err != nil {
105108
log.Errorf("Error collecting topic status: %v", err)
109+
pollError = err
106110
} else {
107111
log.Debugf("Collected all topic status")
108112
}
109113
err = mqmetric.CollectSubStatus(config.cf.MonitoredSubscriptions)
110114
if err != nil {
111115
log.Errorf("Error collecting subscription status: %v", err)
116+
pollError = err
112117
} else {
113118
log.Debugf("Collected all subscription status")
114119
}
120+
err = mqmetric.CollectClusterStatus()
121+
if err != nil {
122+
log.Errorf("Error collecting cluster status: %v", err)
123+
pollError = err
124+
} else {
125+
log.Debugf("Collected all cluster status")
126+
}
115127

116128
err = mqmetric.CollectQueueStatus(config.cf.MonitoredQueues)
117129
if err != nil {
118130
log.Errorf("Error collecting queue status: %v", err)
131+
pollError = err
119132
} else {
120133
log.Debugf("Collected all queue status")
121134
}
@@ -124,11 +137,17 @@ func Collect() error {
124137
err = mqmetric.CollectUsageStatus()
125138
if err != nil {
126139
log.Errorf("Error collecting bufferpool/pageset status: %v", err)
140+
pollError = err
127141
} else {
128142
log.Debugf("Collected all buffer pool/pageset status")
129143
}
130144
}
131145
}
146+
err = pollError
147+
}
148+
149+
if err != nil {
150+
log.Fatalf("Error collecting status: %v", err)
132151
}
133152

134153
thisDiscovery := time.Now()
@@ -287,6 +306,31 @@ func Collect() error {
287306
}
288307
}
289308

309+
series = "cluster"
310+
for _, attr := range mqmetric.GetObjectStatus("", mqmetric.OT_CLUSTER).Attributes {
311+
for key, value := range attr.Values {
312+
if value.IsInt64 {
313+
clusterName := mqmetric.GetObjectStatus("", mqmetric.OT_CLUSTER).Attributes[mqmetric.ATTR_CLUSTER_NAME].Values[key].ValueString
314+
qmType := mqmetric.GetObjectStatus("", mqmetric.OT_CLUSTER).Attributes[mqmetric.ATTR_CLUSTER_QMTYPE].Values[key].ValueInt64
315+
316+
qmTypeString := "PARTIAL"
317+
if qmType == int64(ibmmq.MQQMT_REPOSITORY) {
318+
qmTypeString = "FULL"
319+
}
320+
321+
tags := map[string]string{
322+
"qmgr": config.cf.QMgrName,
323+
"cluster": clusterName,
324+
"qmtype": qmTypeString,
325+
"platform": platformString,
326+
}
327+
328+
f := mqmetric.ClusterNormalise(attr, value.ValueInt64)
329+
printPoint(series, attr.MetricName, float32(f), tags)
330+
}
331+
}
332+
}
333+
290334
series = "qmgr"
291335
for _, attr := range mqmetric.QueueManagerStatus.Attributes {
292336
for _, value := range attr.Values {

cmd/mq_coll/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func main() {
8585
mqmetric.SubInitAttributes()
8686
mqmetric.QueueManagerInitAttributes()
8787
mqmetric.UsageInitAttributes()
88+
mqmetric.ClusterInitAttributes()
8889
}
8990
// What metrics can the queue manager provide? Find out, and
9091
// subscribe.

0 commit comments

Comments
 (0)