Add Elasticsearch index size to Admin dashboard (#27301)
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
340c390849
commit
3171afc36a
1 changed files with 19 additions and 1 deletions
|
@ -11,7 +11,7 @@ class Admin::Metrics::Dimension::SpaceUsageDimension < Admin::Metrics::Dimension
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def perform_query
|
def perform_query
|
||||||
[postgresql_size, redis_size, media_size]
|
[postgresql_size, redis_size, media_size, search_size].compact
|
||||||
end
|
end
|
||||||
|
|
||||||
def postgresql_size
|
def postgresql_size
|
||||||
|
@ -65,4 +65,22 @@ class Admin::Metrics::Dimension::SpaceUsageDimension < Admin::Metrics::Dimension
|
||||||
redis.info
|
redis.info
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def search_size
|
||||||
|
return unless Chewy.enabled?
|
||||||
|
|
||||||
|
client_info = Chewy.client.info
|
||||||
|
|
||||||
|
value = Chewy.client.indices.stats['indices'].values.sum { |index_data| index_data['primaries']['store']['size_in_bytes'] }
|
||||||
|
|
||||||
|
{
|
||||||
|
key: 'search',
|
||||||
|
human_key: client_info.dig('version', 'distribution') == 'opensearch' ? 'OpenSearch' : 'Elasticsearch',
|
||||||
|
value: value.to_s,
|
||||||
|
unit: 'bytes',
|
||||||
|
human_value: number_to_human_size(value),
|
||||||
|
}
|
||||||
|
rescue Faraday::ConnectionFailed, Elasticsearch::Transport::Transport::Error
|
||||||
|
nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue