Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Metricbeat] Implement IBM MQ module #15301

Merged
merged 22 commits into from
Jan 16, 2020
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,8 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Add cost warnings for the azure module. {pull}15356[15356]
- Release elb module as GA. {pull}15485[15485]
- Add a `system/network_summary` metricset {pull}15196[15196]
- Add IBM MQ module {pull}15301[15301]
mtojek marked this conversation as resolved.
Show resolved Hide resolved
- Add IBM MQ light-weight Metricbeat module {pull}15301[15301]
mtojek marked this conversation as resolved.
Show resolved Hide resolved
mtojek marked this conversation as resolved.
Show resolved Hide resolved

*Packetbeat*

Expand Down
9 changes: 9 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ grouped in the following categories:
* <<exported-fields-haproxy>>
* <<exported-fields-host-processor>>
* <<exported-fields-http>>
* <<exported-fields-ibmmq>>
* <<exported-fields-jolokia>>
* <<exported-fields-jolokia-autodiscover>>
* <<exported-fields-kafka>>
Expand Down Expand Up @@ -15840,6 +15841,14 @@ json metricset
server


[[exported-fields-ibmmq]]
== IBM MQ fields

IBM MQ module




[[exported-fields-jolokia]]
== Jolokia fields

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
87 changes: 87 additions & 0 deletions metricbeat/docs/modules/ibmmq.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
////
This file is generated! See scripts/mage/docs_collector.go
////

[[metricbeat-module-ibmmq]]
[role="xpack"]
== IBM MQ module

beta[]

This module periodically fetches metrics from a containerized distribution of IBM MQ.

[float]
=== Compatibility

The ibmmq `qmgr` metricset is compatible with a containerized distribution of IBM MQ (since version 9.1.0).
The Docker image starts the `runmqserver` process, which spawns the HTTP server exposing metrics in Prometheus
format ([source code](https://github.com/ibm-messaging/mq-container/blob/9.1.0/internal/metrics/metrics.go)).

The Docker container lifecycle, including metrics collection, has been described in the [Internals](https://github.com/ibm-messaging/mq-container/blob/9.1.0/docs/internals.md)
document.

The image provides an option to easily enable metrics exporter using an environment
variable:

`MQ_ENABLE_METRICS` - Set this to `true` to generate Prometheus metrics for the Queue Manager.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know which versions of MQ provide the exporter? Do we know how to enable it when not using the Docker image? I'm thinking on how feasible / easy is to go this route in real world deployments (/cc @felix-lessoer @exekias )

Copy link
Contributor Author

@mtojek mtojek Jan 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the questions, @andresrc . Let me respond to these:

Do we know how to enable it when not using the Docker image?

The exporter is available only if you're using the image. It's part of the runmqserver, an application supported running in containerized environments.

The description of the internals is available here: https://github.com/ibm-messaging/mq-container/blob/master/docs/internals.md

Source (main.go) of runmqserver: https://github.com/ibm-messaging/mq-container/blob/master/cmd/runmqserver/main.go

Do we know which versions of MQ provide the exporter?

Not specifically MQ, but the containerized distribution of it. According to the sources, the metrics exporter has been enabled in the release version 9.1.0.

Source code: https://github.com/ibm-messaging/mq-container/tree/9.1.0/internal/metrics

PR: https://github.com/ibm-messaging/mq-container/pull/81/files

I'm thinking on how feasible / easy is to go this route in real world deployments

I think that we can leave a message here that Metricbeat only supports deployments of the official containerized distribution of the MQ. Currently it's the only way to go if we don't want to link the proprietary code.

[float]
=== Dashboard

The ibmmq module includes predefined dashboards with overview information
of the monitored Queue Manager, including subscriptions, calls and messages.

image::./images/metricbeat-ibmmq-calls.png[]

image::./images/metricbeat-ibmmq-messages.png[]

image::./images/metricbeat-ibmmq-subscriptions.png[]


[float]
=== Example configuration

The IBM MQ module supports the standard configuration options that are described
in <<configuration-metricbeat>>. Here is an example configuration:

[source,yaml]
----
metricbeat.modules:
- module: ibmmq
metricsets: ['qmgr']
period: 10s
hosts: ['localhost:9157']

# This module uses the Prometheus collector metricset, all
# the options for this metricset are also available here.
metrics_path: /metrics

processors:
- script:
lang: javascript
source: >
function process(event) {
var metrics = event.Get("prometheus.metrics");
Object.keys(metrics).forEach(function(key) {
if (!(key.match(/^ibmmq_.*$/))) {
event.Delete("prometheus.metrics." + key);
}
});
metrics = event.Get("prometheus.metrics");
if (Object.keys(metrics).length == 0) {
event.Cancel();
}
}
----

It also supports the options described in <<module-http-config-options>>.

[float]
=== Metricsets

The following metricsets are available:

* <<metricbeat-metricset-ibmmq-qmgr,qmgr>>

include::ibmmq/qmgr.asciidoc[]

24 changes: 24 additions & 0 deletions metricbeat/docs/modules/ibmmq/qmgr.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
////
This file is generated! See scripts/mage/docs_collector.go
////

[[metricbeat-metricset-ibmmq-qmgr]]
=== IBM MQ qmgr metricset

beta[]

include::../../../../x-pack/metricbeat/module/ibmmq/qmgr/_meta/docs.asciidoc[]

This is a default metricset. If the host module is unconfigured, this metricset is enabled by default.

==== Fields

For a description of each field in the metricset, see the
<<exported-fields-ibmmq,exported fields>> section.

Here is an example document generated by this metricset:

[source,json]
----
include::../../../../x-pack/metricbeat/module/ibmmq/qmgr/_meta/data.json[]
----
3 changes: 3 additions & 0 deletions metricbeat/docs/modules_list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ This file is generated! See scripts/mage/docs_collector.go
|<<metricbeat-module-http,HTTP>> |image:./images/icon-no.png[No prebuilt dashboards] |
.2+| .2+| |<<metricbeat-metricset-http-json,json>>
|<<metricbeat-metricset-http-server,server>>
|<<metricbeat-module-ibmmq,IBM MQ>> beta[] |image:./images/icon-yes.png[Prebuilt dashboards are available] |
.1+| .1+| |<<metricbeat-metricset-ibmmq-qmgr,qmgr>> beta[]
|<<metricbeat-module-jolokia,Jolokia>> |image:./images/icon-no.png[No prebuilt dashboards] |
.1+| .1+| |<<metricbeat-metricset-jolokia-jmx,jmx>>
|<<metricbeat-module-kafka,Kafka>> |image:./images/icon-yes.png[Prebuilt dashboards are available] |
Expand Down Expand Up @@ -254,6 +256,7 @@ include::modules/googlecloud.asciidoc[]
include::modules/graphite.asciidoc[]
include::modules/haproxy.asciidoc[]
include::modules/http.asciidoc[]
include::modules/ibmmq.asciidoc[]
include::modules/jolokia.asciidoc[]
include::modules/kafka.asciidoc[]
include::modules/kibana.asciidoc[]
Expand Down
1 change: 1 addition & 0 deletions x-pack/metricbeat/include/list.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions x-pack/metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,33 @@ metricbeat.modules:
# fields: # added to the the response in root. overwrites existing fields
# key: "value"

#-------------------------------- IBM MQ Module --------------------------------
- module: ibmmq
metricsets: ['qmgr']
period: 10s
hosts: ['localhost:9157']

# This module uses the Prometheus collector metricset, all
# the options for this metricset are also available here.
metrics_path: /metrics

processors:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a short comment/description here of why we decided to use js processor here could be of worth

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added!

- script:
lang: javascript
source: >
function process(event) {
var metrics = event.Get("prometheus.metrics");
Object.keys(metrics).forEach(function(key) {
if (!(key.match(/^ibmmq_.*$/))) {
event.Delete("prometheus.metrics." + key);
}
});
metrics = event.Get("prometheus.metrics");
if (Object.keys(metrics).length == 0) {
event.Cancel();
}
}

#------------------------------- Jolokia Module -------------------------------
- module: jolokia
#metricsets: ["jmx"]
Expand Down
11 changes: 11 additions & 0 deletions x-pack/metricbeat/module/ibmmq/_meta/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ARG IBMMQ_VERSION

FROM ibmcom/mq:${IBMMQ_VERSION}

ENV IBMMQ_METRICS_REST_PORT=9157

ENV LICENSE=accept
ENV MQ_QMGR_NAME=QM1
ENV MQ_ENABLE_METRICS=true

HEALTHCHECK --interval=1s --retries=90 CMD curl -s --fail http://127.0.0.1:${IBMMQ_METRICS_REST_PORT}/metrics | grep -q "ibmmq_qmgr_commit_total"
25 changes: 25 additions & 0 deletions x-pack/metricbeat/module/ibmmq/_meta/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- module: ibmmq
metricsets: ['qmgr']
period: 10s
hosts: ['localhost:9157']

# This module uses the Prometheus collector metricset, all
# the options for this metricset are also available here.
metrics_path: /metrics

processors:
- script:
lang: javascript
source: >
function process(event) {
var metrics = event.Get("prometheus.metrics");
Object.keys(metrics).forEach(function(key) {
if (!(key.match(/^ibmmq_.*$/))) {
event.Delete("prometheus.metrics." + key);
}
});
metrics = event.Get("prometheus.metrics");
if (Object.keys(metrics).length == 0) {
event.Cancel();
}
}
28 changes: 28 additions & 0 deletions x-pack/metricbeat/module/ibmmq/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
This module periodically fetches metrics from a containerized distribution of IBM MQ.

[float]
=== Compatibility

The ibmmq `qmgr` metricset is compatible with a containerized distribution of IBM MQ (since version 9.1.0).
The Docker image starts the `runmqserver` process, which spawns the HTTP server exposing metrics in Prometheus
format ([source code](https://github.com/ibm-messaging/mq-container/blob/9.1.0/internal/metrics/metrics.go)).

The Docker container lifecycle, including metrics collection, has been described in the [Internals](https://github.com/ibm-messaging/mq-container/blob/9.1.0/docs/internals.md)
document.

The image provides an option to easily enable metrics exporter using an environment
variable:

`MQ_ENABLE_METRICS` - Set this to `true` to generate Prometheus metrics for the Queue Manager.

[float]
=== Dashboard

The ibmmq module includes predefined dashboards with overview information
of the monitored Queue Manager, including subscriptions, calls and messages.

image::./images/metricbeat-ibmmq-calls.png[]

image::./images/metricbeat-ibmmq-messages.png[]

image::./images/metricbeat-ibmmq-subscriptions.png[]
10 changes: 10 additions & 0 deletions x-pack/metricbeat/module/ibmmq/_meta/fields.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- key: ibmmq
title: 'IBM MQ'
release: beta
description: >
IBM MQ module
settings: ["http"]
fields:
- name: ibmmq
type: group
fields:
Loading