Skip to content

Commit

Permalink
Make use of prometheus filter settings on IBM-MQ Metricbeat module (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ma-hei authored Mar 17, 2020
1 parent b6167ae commit 0208a25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
28 changes: 4 additions & 24 deletions x-pack/metricbeat/module/ibmmq/qmgr/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,7 @@ input:
metricset: collector
defaults:
metrics_path: /metrics

# The custom processor is responsible for filtering Prometheus metrics
# not stricly related to the IBM MQ domain, e.g. system load, process,
# metrics HTTP server.
processors:
- script:
lang: javascript
source: >
function process(event) {
var metrics = event.Get("prometheus.metrics");
if (metrics == null) {
event.Cancel();
return;
}
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();
}
}
# Filtering out Prometheus metrics that are not strictly related to the
# IBM MQ domain, e.g. system load, process, metrics HTTP server.
metrics_filters:
include: ["ibmmq_.*", "^up$"]
2 changes: 1 addition & 1 deletion x-pack/metricbeat/module/ibmmq/test_ibmmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ def test_qmgr(self):

# Verify if processors are correctly setup.
for metric in evt["prometheus"]["metrics"].keys():
assert metric.startswith("ibmmq_")
assert metric.startswith("ibmmq_") or metric == "up"

0 comments on commit 0208a25

Please sign in to comment.