mirror of
https://github.com/funamitech/mastodon
synced 2024-11-27 22:38:42 +09:00
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
@ -11,7 +11,7 @@ class Admin::Metrics::Dimension::SpaceUsageDimension < Admin::Metrics::Dimension
|
||||
protected
|
||||
|
||||
def perform_query
|
||||
[postgresql_size, redis_size, media_size]
|
||||
[postgresql_size, redis_size, media_size, search_size].compact
|
||||
end
|
||||
|
||||
def postgresql_size
|
||||
@ -65,4 +65,22 @@ class Admin::Metrics::Dimension::SpaceUsageDimension < Admin::Metrics::Dimension
|
||||
redis.info
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user