diff --git a/x-pack/plugins/monitoring/server/lib/metrics/logstash/classes.js b/x-pack/plugins/monitoring/server/lib/metrics/logstash/classes.js index 3221924152208..8b1729d1cced2 100644 --- a/x-pack/plugins/monitoring/server/lib/metrics/logstash/classes.js +++ b/x-pack/plugins/monitoring/server/lib/metrics/logstash/classes.js @@ -408,6 +408,27 @@ export class LogstashPipelineNodeCountMetric extends LogstashMetric { } } } + }, + no_pipelines: { + filter: { + bool: { + must_not: { + nested: { + path: 'logstash_stats.pipelines', + query: { + match_all: {} + } + } + } + } + }, + aggs: { + node_count: { + cardinality: { + field: this.field + } + } + } } } } @@ -427,6 +448,15 @@ export class LogstashPipelineNodeCountMetric extends LogstashMetric { ); }); + const DEFAULT_PIPELINE_ID = 'main'; // FIXME: Move to common constants + const oldNodesCount = _.get(bucket, 'no_pipelines.node_count.value', 0) + if (oldNodesCount > 0) { + if (!pipelineNodesCounts.hasOwnProperty(DEFAULT_PIPELINE_ID)) { + pipelineNodesCounts[DEFAULT_PIPELINE_ID] = 0 + } + pipelineNodesCounts[DEFAULT_PIPELINE_ID] += oldNodesCount + } + return pipelineNodesCounts; }; }