Add Elasticsearch/OpenSearch version to “Software” in admin dashboard (#26652)

This commit is contained in:
Claire 2023-08-25 12:02:09 +02:00 committed by GitHub
parent e3825a13c1
commit f2ec2876a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 1 deletions

View File

@ -10,7 +10,7 @@ class Admin::Metrics::Dimension::SoftwareVersionsDimension < Admin::Metrics::Dim
protected protected
def perform_query def perform_query
[mastodon_version, ruby_version, postgresql_version, redis_version] [mastodon_version, ruby_version, postgresql_version, redis_version, elasticsearch_version].compact
end end
def mastodon_version def mastodon_version
@ -57,6 +57,22 @@ class Admin::Metrics::Dimension::SoftwareVersionsDimension < Admin::Metrics::Dim
} }
end end
def elasticsearch_version
return unless Chewy.enabled?
client_info = Chewy.client.info
version = client_info.dig('version', 'number')
{
key: 'elasticsearch',
human_key: client_info.dig('version', 'distribution') == 'opensearch' ? 'OpenSearch' : 'Elasticsearch',
value: version,
human_value: version,
}
rescue Faraday::ConnectionFailed, Elasticsearch::Transport::Transport::Error
nil
end
def redis_info def redis_info
@redis_info ||= if redis.is_a?(Redis::Namespace) @redis_info ||= if redis.is_a?(Redis::Namespace)
redis.redis.info redis.redis.info