Add graph?=true parameter

Fixes #10561
This commit is contained in:
Mike Place 2019-04-03 15:25:39 -06:00 committed by Shaunak Kashyap
parent 8fd6e58e78
commit 592591bae9
2 changed files with 8 additions and 4 deletions

View file

@ -24,10 +24,9 @@ module LogStash
end
end
def pipeline(pipeline_id)
extract_metrics(
def pipeline(pipeline_id, options={})
metrics = extract_metrics(
[:stats, :pipelines, pipeline_id.to_sym, :config],
:graph,
:ephemeral_id,
:hash,
:workers,
@ -39,6 +38,10 @@ module LogStash
:dead_letter_queue_path,
:cluster_uuids
).reject{|_, v|v.nil?}
if options.fetch(:graph, false)
metrics.merge!(extract_metrics([:stats, :pipelines, pipeline_id.to_sym, :config], :graph))
end
metrics
rescue
{}
end

View file

@ -28,7 +28,8 @@ module LogStash
get "/pipelines/:id" do
pipeline_id = params["id"]
payload = node.pipeline(pipeline_id)
opts = {:graph => as_boolean(params.fetch("graph", false))}
payload = node.pipeline(pipeline_id, opts)
halt(404) if payload.empty?
respond_with(:pipelines => { pipeline_id => payload } )
end