Skip to content

Commit 3d51c44

Browse files
committed
Merge branch 'dol-feature/add-custom-data-as-tag-or-label'
2 parents 6ba0f32 + cbe31d3 commit 3d51c44

File tree

18 files changed

+268
-13
lines changed

18 files changed

+268
-13
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22
Newest updates are at the top of this file.
33

4+
### xxx xx 2025 (v5.6.5)
5+
* Update to MQ 9.4.4
6+
* Add showCustomAttribute filter config setting to include the CUSTOM attribute as metric tag/label
7+
48
### Jun 19 2025 (no new version)
59
* Improve container building
610

@@ -19,6 +23,7 @@ Newest updates are at the top of this file.
1923
### Unreleased
2024
* Fix boolean logic for `isFirstCollection` in `mq_prometheus (#385)`
2125
* Ensure proper collection on the first poll and at regular intervals thereafter
26+
* Add showCustomAttribute filter config setting to include the CUSTOM attribute as metric tag/label
2227

2328
### Feb 28 2025 (v5.6.2)
2429
* Update to MQ 9.4.2

cmd/mq_aws/exporter.go

Lines changed: 17 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,2022
4+
Copyright (c) IBM Corporation 2016,2025
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.
@@ -264,6 +264,9 @@ func Collect() error {
264264
if hostname != mqmetric.DUMMY_STRING {
265265
tags["hostname"] = hostname
266266
}
267+
if showAndSupportsCustomLabel() {
268+
tags["custom"] = mqmetric.GetObjectCustom("", ibmmq.MQOT_Q_MGR)
269+
}
267270
} else if strings.HasPrefix(key, mqmetric.NativeHAKeyPrefix) {
268271
series = "nha"
269272
tags["nha"] = strings.Replace(key, mqmetric.NativeHAKeyPrefix, "", -1)
@@ -283,6 +286,9 @@ func Collect() error {
283286
tags["usage"] = usage
284287
tags["description"] = mqmetric.GetObjectDescription(key, ibmmq.MQOT_Q)
285288
tags["cluster"] = mqmetric.GetQueueAttribute(key, ibmmq.MQCA_CLUSTER_NAME)
289+
if showAndSupportsCustomLabel() {
290+
tags["custom"] = mqmetric.GetObjectCustom(key, ibmmq.MQOT_Q)
291+
}
286292
}
287293
addMetaLabels(tags)
288294

@@ -371,6 +377,9 @@ func Collect() error {
371377
tags["usage"] = usage
372378
tags["description"] = mqmetric.GetObjectDescription(key, ibmmq.MQOT_Q)
373379
tags["cluster"] = mqmetric.GetQueueAttribute(key, ibmmq.MQCA_CLUSTER_NAME)
380+
if showAndSupportsCustomLabel() {
381+
tags["custom"] = mqmetric.GetObjectCustom(key, ibmmq.MQOT_Q)
382+
}
374383
addMetaLabels(tags)
375384

376385
f := mqmetric.QueueNormalise(attr, value.ValueInt64)
@@ -496,6 +505,9 @@ func Collect() error {
496505
if hostname != mqmetric.DUMMY_STRING {
497506
tags["hostname"] = hostname
498507
}
508+
if showAndSupportsCustomLabel() {
509+
tags["custom"] = mqmetric.GetObjectCustom("", ibmmq.MQOT_Q_MGR)
510+
}
499511
addMetaLabels(tags)
500512

501513
f := mqmetric.QueueManagerNormalise(attr, value.ValueInt64)
@@ -690,3 +702,7 @@ func addMetaLabels(tags map[string]string) {
690702
}
691703
}
692704
}
705+
706+
func showAndSupportsCustomLabel() bool {
707+
return config.cf.CC.ShowCustomAttribute
708+
}

cmd/mq_coll/exporter.go

Lines changed: 17 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 2022
4+
Copyright (c) IBM Corporation 2022, 2025
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.
@@ -216,6 +216,9 @@ func Collect() error {
216216
if hostname != mqmetric.DUMMY_STRING {
217217
tags["hostname"] = hostname
218218
}
219+
if showAndSupportsCustomLabel() {
220+
tags["custom"] = mqmetric.GetObjectCustom("", ibmmq.MQOT_Q_MGR)
221+
}
219222
} else if strings.HasPrefix(key, mqmetric.NativeHAKeyPrefix) {
220223
series = "nha"
221224
tags["nha"] = strings.Replace(key, mqmetric.NativeHAKeyPrefix, "", -1)
@@ -234,6 +237,9 @@ func Collect() error {
234237
tags["usage"] = usage
235238
tags["description"] = mqmetric.GetObjectDescription(key, ibmmq.MQOT_Q)
236239
tags["cluster"] = mqmetric.GetQueueAttribute(key, ibmmq.MQCA_CLUSTER_NAME)
240+
if showAndSupportsCustomLabel() {
241+
tags["custom"] = mqmetric.GetObjectCustom(key, ibmmq.MQOT_Q)
242+
}
237243
}
238244
addMetaLabels(tags)
239245

@@ -306,6 +312,9 @@ func Collect() error {
306312
tags["usage"] = usage
307313
tags["description"] = mqmetric.GetObjectDescription(key, ibmmq.MQOT_Q)
308314
tags["cluster"] = mqmetric.GetQueueAttribute(key, ibmmq.MQCA_CLUSTER_NAME)
315+
if showAndSupportsCustomLabel() {
316+
tags["custom"] = mqmetric.GetObjectCustom(key, ibmmq.MQOT_Q)
317+
}
309318
addMetaLabels(tags)
310319

311320
f := mqmetric.QueueNormalise(attr, value.ValueInt64)
@@ -405,6 +414,9 @@ func Collect() error {
405414
if hostname != mqmetric.DUMMY_STRING {
406415
tags["hostname"] = hostname
407416
}
417+
if showAndSupportsCustomLabel() {
418+
tags["custom"] = mqmetric.GetObjectCustom("", ibmmq.MQOT_Q_MGR)
419+
}
408420
addMetaLabels(tags)
409421

410422
f := mqmetric.QueueManagerNormalise(attr, value.ValueInt64)
@@ -571,3 +583,7 @@ func addMetaLabels(tags map[string]string) {
571583
}
572584
}
573585
}
586+
587+
func showAndSupportsCustomLabel() bool {
588+
return config.cf.CC.ShowCustomAttribute
589+
}

cmd/mq_influx/exporter.go

Lines changed: 17 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,2022
4+
Copyright (c) IBM Corporation 2016,2025
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.
@@ -247,6 +247,9 @@ func Collect(c client.Client) error {
247247
if hostname != mqmetric.DUMMY_STRING {
248248
tags["hostname"] = hostname
249249
}
250+
if showAndSupportsCustomLabel() {
251+
tags["custom"] = mqmetric.GetObjectCustom("", ibmmq.MQOT_Q_MGR)
252+
}
250253
} else if strings.HasPrefix(key, mqmetric.NativeHAKeyPrefix) {
251254
series = "nha"
252255
tags["nha"] = strings.Replace(key, mqmetric.NativeHAKeyPrefix, "", -1)
@@ -266,6 +269,9 @@ func Collect(c client.Client) error {
266269
tags["usage"] = usage
267270
tags["description"] = mqmetric.GetObjectDescription(key, ibmmq.MQOT_Q)
268271
tags["cluster"] = mqmetric.GetQueueAttribute(key, ibmmq.MQCA_CLUSTER_NAME)
272+
if showAndSupportsCustomLabel() {
273+
tags["custom"] = mqmetric.GetObjectCustom(key, ibmmq.MQOT_Q)
274+
}
269275
addMetaLabels(tags)
270276

271277
}
@@ -346,6 +352,9 @@ func Collect(c client.Client) error {
346352
tags["usage"] = usage
347353
tags["description"] = mqmetric.GetObjectDescription(key, ibmmq.MQOT_Q)
348354
tags["cluster"] = mqmetric.GetQueueAttribute(key, ibmmq.MQCA_CLUSTER_NAME)
355+
if showAndSupportsCustomLabel() {
356+
tags["custom"] = mqmetric.GetObjectCustom(key, ibmmq.MQOT_Q)
357+
}
349358
addMetaLabels(tags)
350359

351360
f := mqmetric.QueueNormalise(attr, value.ValueInt64)
@@ -464,6 +473,9 @@ func Collect(c client.Client) error {
464473
if hostname != mqmetric.DUMMY_STRING {
465474
tags["hostname"] = hostname
466475
}
476+
if showAndSupportsCustomLabel() {
477+
tags["custom"] = mqmetric.GetObjectCustom("", ibmmq.MQOT_Q_MGR)
478+
}
467479
addMetaLabels(tags)
468480

469481
f := mqmetric.QueueManagerNormalise(attr, value.ValueInt64)
@@ -621,3 +633,7 @@ func addMetaLabels(tags map[string]string) {
621633
}
622634
}
623635
}
636+
637+
func showAndSupportsCustomLabel() bool {
638+
return config.cf.CC.ShowCustomAttribute
639+
}

cmd/mq_json/exporter.go

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

33
/*
4-
Copyright (c) IBM Corporation 2016, 2022
4+
Copyright (c) IBM Corporation 2016, 2025
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.
@@ -245,6 +245,9 @@ func Collect() error {
245245
if hostname != mqmetric.DUMMY_STRING {
246246
pt.Tags["hostname"] = hostname
247247
}
248+
if showAndSupportsCustomLabel() {
249+
pt.Tags["custom"] = mqmetric.GetObjectCustom("", ibmmq.MQOT_Q_MGR)
250+
}
248251
} else if strings.HasPrefix(key, mqmetric.NativeHAKeyPrefix) {
249252
pt.Tags["nha"] = strings.Replace(key, mqmetric.NativeHAKeyPrefix, "", -1)
250253
pt.ObjectType = "nha"
@@ -256,7 +259,9 @@ func Collect() error {
256259
pt.ObjectType = "queue"
257260
pt.Tags["description"] = mqmetric.GetObjectDescription(key, ibmmq.MQOT_Q)
258261
pt.Tags["cluster"] = mqmetric.GetQueueAttribute(key, ibmmq.MQCA_CLUSTER_NAME)
259-
262+
if showAndSupportsCustomLabel() {
263+
pt.Tags["custom"] = mqmetric.GetObjectCustom(key, ibmmq.MQOT_Q)
264+
}
260265
}
261266
addMetaLabels(pt.Tags)
262267
}
@@ -345,6 +350,9 @@ func Collect() error {
345350
pt.Tags["queue"] = qName
346351
pt.Tags["usage"] = usageString
347352
pt.Tags["description"] = mqmetric.GetObjectDescription(qName, ibmmq.MQOT_Q)
353+
if showAndSupportsCustomLabel() {
354+
pt.Tags["custom"] = mqmetric.GetObjectCustom(qName, ibmmq.MQOT_Q)
355+
}
348356
pt.Tags["cluster"] = mqmetric.GetQueueAttribute(key, ibmmq.MQCA_CLUSTER_NAME)
349357
pt.Tags["platform"] = platformString
350358
addMetaLabels(pt.Tags)
@@ -400,6 +408,9 @@ func Collect() error {
400408
pt.Tags["qmgr"] = strings.TrimSpace(qMgrName)
401409
pt.Tags["platform"] = platformString
402410
pt.Tags["description"] = mqmetric.GetObjectDescription("", ibmmq.MQOT_Q_MGR)
411+
if showAndSupportsCustomLabel() {
412+
pt.Tags["custom"] = mqmetric.GetObjectCustom("", ibmmq.MQOT_Q_MGR)
413+
}
403414
hostname := mqmetric.GetQueueManagerAttribute(config.cf.QMgrName, ibmmq.MQCACF_HOST_NAME)
404415
if hostname != mqmetric.DUMMY_STRING {
405416
pt.Tags["hostname"] = hostname
@@ -695,3 +706,7 @@ func addMetaLabels(tags map[string]string) {
695706
}
696707
}
697708
}
709+
710+
func showAndSupportsCustomLabel() bool {
711+
return config.cf.CC.ShowCustomAttribute
712+
}

cmd/mq_opentsdb/exporter.go

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

33
/*
4-
Copyright (c) IBM Corporation 2016,2022
4+
Copyright (c) IBM Corporation 2016,2025
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.
@@ -247,6 +247,9 @@ func Collect() error {
247247
if hostname != mqmetric.DUMMY_STRING {
248248
tags["hostname"] = hostname
249249
}
250+
if showAndSupportsCustomLabel() {
251+
tags["custom"] = mqmetric.GetObjectCustom("", ibmmq.MQOT_Q_MGR)
252+
}
250253
} else if strings.HasPrefix(key, mqmetric.NativeHAKeyPrefix) {
251254
series = "nha"
252255
tags["nha"] = strings.Replace(key, mqmetric.NativeHAKeyPrefix, "", -1)
@@ -265,7 +268,9 @@ func Collect() error {
265268
tags["usage"] = usage
266269
tags["description"] = mqmetric.GetObjectDescription(key, ibmmq.MQOT_Q)
267270
tags["cluster"] = mqmetric.GetQueueAttribute(key, ibmmq.MQCA_CLUSTER_NAME)
268-
271+
if showAndSupportsCustomLabel() {
272+
tags["custom"] = mqmetric.GetObjectCustom(key, ibmmq.MQOT_Q)
273+
}
269274
}
270275
addMetaLabels(tags)
271276

@@ -351,6 +356,9 @@ func Collect() error {
351356
tags["usage"] = usage
352357
tags["description"] = mqmetric.GetObjectDescription(key, ibmmq.MQOT_Q)
353358
tags["cluster"] = mqmetric.GetQueueAttribute(key, ibmmq.MQCA_CLUSTER_NAME)
359+
if showAndSupportsCustomLabel() {
360+
tags["custom"] = mqmetric.GetObjectCustom(key, ibmmq.MQOT_Q)
361+
}
354362
addMetaLabels(tags)
355363

356364
f := mqmetric.QueueNormalise(attr, value.ValueInt64)
@@ -473,6 +481,9 @@ func Collect() error {
473481
if hostname != mqmetric.DUMMY_STRING {
474482
tags["hostname"] = hostname
475483
}
484+
if showAndSupportsCustomLabel() {
485+
tags["custom"] = mqmetric.GetObjectCustom("", ibmmq.MQOT_Q_MGR)
486+
}
476487
addMetaLabels(tags)
477488

478489
f := mqmetric.QueueManagerNormalise(attr, value.ValueInt64)
@@ -707,3 +718,7 @@ func addMetaLabels(tags map[string]string) {
707718
}
708719
}
709720
}
721+
722+
func showAndSupportsCustomLabel() bool {
723+
return config.cf.CC.ShowCustomAttribute
724+
}

cmd/mq_otel/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,19 @@ package source code. But they include:
5555
- `OTEL_EXPORTER_OTLP_METRICS_INSECURE`
5656
- `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT`
5757

58+
The `*HEADERS` can be used to add header information to the flows, which might permit
59+
use of Basic Auth options for communication to the collector. Something like:
60+
```
61+
s="$user:$password"
62+
b=`echo $s | base64`
63+
v="Basic $b"
64+
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=\"$v\""
65+
```
66+
67+
There is also the `OTEL_RESOURCE_ATTRIBUTES` environment variable, allowing additional key/value
68+
pairs to be added to the reported spans. This propagator does not explicit use that variable as it
69+
does not emit its own spans. But it might be useful for other aspects of your application.
70+
5871

5972
For test purposes, you can get the default OpenTelemetry Collector program running in a container with
6073
```

cmd/mq_otel/reader.go

Lines changed: 17 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 2024
4+
Copyright (c) IBM Corporation 2024, 2025
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.
@@ -374,6 +374,9 @@ func GetMetrics(ctx context.Context, meter metric.Meter) error {
374374
if hostname != mqmetric.DUMMY_STRING {
375375
tags["hostname"] = hostname
376376
}
377+
if showAndSupportsCustomLabel() {
378+
tags["custom"] = mqmetric.GetObjectCustom("", ibmmq.MQOT_Q_MGR)
379+
}
377380
} else if strings.HasPrefix(key, mqmetric.NativeHAKeyPrefix) {
378381
series = "nha"
379382
tags["nha"] = strings.Replace(key, mqmetric.NativeHAKeyPrefix, "", -1)
@@ -392,6 +395,9 @@ func GetMetrics(ctx context.Context, meter metric.Meter) error {
392395
tags["usage"] = usage
393396
tags["description"] = mqmetric.GetObjectDescription(key, ibmmq.MQOT_Q)
394397
tags["cluster"] = mqmetric.GetQueueAttribute(key, ibmmq.MQCA_CLUSTER_NAME)
398+
if showAndSupportsCustomLabel() {
399+
tags["custom"] = mqmetric.GetObjectCustom(key, ibmmq.MQOT_Q)
400+
}
395401
}
396402

397403
addMetaLabels(tags)
@@ -426,6 +432,9 @@ func GetMetrics(ctx context.Context, meter metric.Meter) error {
426432
tags["usage"] = usage
427433
tags["description"] = mqmetric.GetObjectDescription(key, ibmmq.MQOT_Q)
428434
tags["cluster"] = mqmetric.GetQueueAttribute(key, ibmmq.MQCA_CLUSTER_NAME)
435+
if showAndSupportsCustomLabel() {
436+
tags["custom"] = mqmetric.GetObjectCustom(key, ibmmq.MQOT_Q)
437+
}
429438
addMetaLabels(tags)
430439

431440
f := mqmetric.QueueNormalise(attr, value.ValueInt64)
@@ -567,6 +576,9 @@ func GetMetrics(ctx context.Context, meter metric.Meter) error {
567576
if hostname != mqmetric.DUMMY_STRING {
568577
tags["hostname"] = hostname
569578
}
579+
if showAndSupportsCustomLabel() {
580+
tags["custom"] = mqmetric.GetObjectCustom("", ibmmq.MQOT_Q_MGR)
581+
}
570582
addMetaLabels(tags)
571583

572584
f := mqmetric.QueueManagerNormalise(attr, value.ValueInt64)
@@ -700,3 +712,7 @@ func addMetaLabels(tags map[string]string) {
700712
}
701713
}
702714
}
715+
716+
func showAndSupportsCustomLabel() bool {
717+
return config.cf.CC.ShowCustomAttribute
718+
}

0 commit comments

Comments
 (0)