From de6a6c5b0f64cc4fada6e3f22b2dddedd484491e Mon Sep 17 00:00:00 2001 From: kaisecheng <69120390+kaisecheng@users.noreply.github.com> Date: Fri, 3 Jan 2025 20:48:14 +0000 Subject: [PATCH] Add pipeline metrics to Node Stats API (#16839) This commit introduces three new metrics per pipeline in the Node Stats API: - workers - batch_size - batch_delay ``` { ... pipelines: { main: { events: {...}, flow: {...}, plugins: {...}, reloads: {...}, queue: {...}, pipeline: { workers: 12, batch_size: 125, batch_delay: 5, }, } } ... } ``` --- docs/static/monitoring/monitoring-apis.asciidoc | 15 +++++++++++++++ logstash-core/lib/logstash/api/commands/stats.rb | 7 ++++++- .../spec/logstash/api/commands/stats_spec.rb | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/static/monitoring/monitoring-apis.asciidoc b/docs/static/monitoring/monitoring-apis.asciidoc index c9d8d7c702a..7c68838b81b 100644 --- a/docs/static/monitoring/monitoring-apis.asciidoc +++ b/docs/static/monitoring/monitoring-apis.asciidoc @@ -726,6 +726,11 @@ Example response: }, "queue" : { "type" : "memory" + }, + "pipeline": { + "workers": 4, + "batch_size": 125, + "batch_delay": 50 } }, "test2" : { @@ -807,6 +812,11 @@ Example response: }, "queue" : { "type" : "memory" + }, + "pipeline": { + "workers": 4, + "batch_size": 125, + "batch_delay": 50 } } } @@ -969,6 +979,11 @@ Example response: "events_count": 0, "queue_size_in_bytes": 3885, "max_queue_size_in_bytes": 1073741824 + }, + "pipeline": { + "workers": 4, + "batch_size": 125, + "batch_delay": 50 } } } diff --git a/logstash-core/lib/logstash/api/commands/stats.rb b/logstash-core/lib/logstash/api/commands/stats.rb index 5c55d46082e..cd26524b27a 100644 --- a/logstash-core/lib/logstash/api/commands/stats.rb +++ b/logstash-core/lib/logstash/api/commands/stats.rb @@ -183,7 +183,12 @@ def report(stats, extended_stats = nil, opts = {}) :outputs => plugin_stats(stats, :outputs) }, :reloads => stats[:reloads], - :queue => stats[:queue] + :queue => stats[:queue], + :pipeline => { + :workers => stats[:config][:workers], + :batch_size => stats[:config][:batch_size], + :batch_delay => stats[:config][:batch_delay], + } } ret[:dead_letter_queue] = stats[:dlq] if stats.include?(:dlq) diff --git a/logstash-core/spec/logstash/api/commands/stats_spec.rb b/logstash-core/spec/logstash/api/commands/stats_spec.rb index 7c9d36a8364..fbe01ba2704 100644 --- a/logstash-core/spec/logstash/api/commands/stats_spec.rb +++ b/logstash-core/spec/logstash/api/commands/stats_spec.rb @@ -162,6 +162,7 @@ :plugins, :reloads, :queue, + :pipeline ) end it "returns event information" do