api: avoid 5xx when stats/events not yet populated (#13424) (#13845)

* api: avoid 5xx when stats/events not yet populated

* Add catching of metrics exception also for retrieve of :queue metrics. No pipelines means no queues created

* Added empty result when no pipelines is present and query for node info API

Co-authored-by: andsel <selva.andre@gmail.com>
(cherry picked from commit a6c0e75b53)
This commit is contained in:
Ry Biesemeyer 2022-03-07 11:04:18 -08:00 committed by GitHub
parent 5d0ad6ea38
commit a491462e69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View file

@ -38,6 +38,8 @@ module LogStash
pipeline_ids.each_with_object({}) do |pipeline_id, result|
result[pipeline_id] = pipeline(pipeline_id, options)
end
rescue Instrument::MetricStore::MetricNotFound
{}
end
def pipeline(pipeline_id, options={})

View file

@ -39,6 +39,8 @@ module LogStash
end
{:events_count => total_queued_events}
rescue Instrument::MetricStore::MetricNotFound
{}
end
def jvm
@ -74,6 +76,9 @@ module LogStash
[:stats, :events],
:in, :filtered, :out, :duration_in_millis, :queue_push_duration_in_millis
)
rescue Instrument::MetricStore::MetricNotFound
# if the stats/events metrics have not yet been populated, return an empty map
{}
end
def pipeline(pipeline_id = nil, opts={})