Class: Fluent::Plugin::ElasticsearchStats::Client
- Inherits:
-
Object
- Object
- Fluent::Plugin::ElasticsearchStats::Client
- Defined in:
- lib/fluent/plugin/elasticsearch_stats/client.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- TIMEOUT =
10- USER_AGENT =
'elasticsearch_stats'- LOCAL =
false- CLUSTER_HEALTH_LEVEL =
'cluster'- NODES_STATS_LEVEL =
'cluster'- INDICES_STATS_LEVEL =
'indices'- INDICES =
[:_all]
- ALLOWED_CLUSTER_HEALTH_LEVELS =
%i[cluster indices shards].freeze
- ALLOWED_NODES_STATS_LEVELS =
%i[nodes indices shards].freeze
- ALLOWED_NODES_STATS_METRICS =
%i[ adaptive_selection breaker discovery fs http indexing_pressure indices ingest jvm os process repositories thread_pool transport ].freeze
- ALLOWED_INDICES_LEVELS =
%i[cluster indices shards].freeze
- ALLOWED_INDICES_METRICS =
%i[ _all completion docs fielddata flush get indexing merge query_cache refresh request_cache search segments store translog ].freeze
Instance Attribute Summary collapse
-
#ca_file ⇒ Object
readonly
Returns the value of attribute ca_file.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#log ⇒ Object
readonly
Returns the value of attribute log.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#user_agent ⇒ Object
readonly
Returns the value of attribute user_agent.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
-
#verify_ssl ⇒ Object
readonly
Returns the value of attribute verify_ssl.
Instance Method Summary collapse
- #cluster_health(level: CLUSTER_HEALTH_LEVEL, local: LOCAL) ⇒ Object
- #cluster_stats ⇒ Object
- #dangling ⇒ Object
- #indices_stats(indices: INDICES, level: INDICES_STATS_LEVEL, metrics: nil) ⇒ Object
-
#initialize(url:, timeout: TIMEOUT, username: nil, password: nil, user_agent: USER_AGENT, ca_file: nil, verify_ssl: true, log: nil) ⇒ Client
constructor
A new instance of Client.
- #nodes_stats(level: NODES_STATS_LEVEL, metrics: nil) ⇒ Object
Constructor Details
#initialize(url:, timeout: TIMEOUT, username: nil, password: nil, user_agent: USER_AGENT, ca_file: nil, verify_ssl: true, log: nil) ⇒ Client
Returns a new instance of Client.
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/fluent/plugin/elasticsearch_stats/client.rb', line 61 def initialize(url:, timeout: TIMEOUT, username: nil, password: nil, user_agent: USER_AGENT, ca_file: nil, verify_ssl: true, log: nil) @url = url @timeout = timeout @username = username @password = password @user_agent = user_agent @ca_file = ca_file @verify_ssl = verify_ssl @log = log end |
Instance Attribute Details
#ca_file ⇒ Object (readonly)
Returns the value of attribute ca_file.
58 59 60 |
# File 'lib/fluent/plugin/elasticsearch_stats/client.rb', line 58 def ca_file @ca_file end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
58 59 60 |
# File 'lib/fluent/plugin/elasticsearch_stats/client.rb', line 58 def client @client end |
#log ⇒ Object (readonly)
Returns the value of attribute log.
58 59 60 |
# File 'lib/fluent/plugin/elasticsearch_stats/client.rb', line 58 def log @log end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
58 59 60 |
# File 'lib/fluent/plugin/elasticsearch_stats/client.rb', line 58 def password @password end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
58 59 60 |
# File 'lib/fluent/plugin/elasticsearch_stats/client.rb', line 58 def timeout @timeout end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
58 59 60 |
# File 'lib/fluent/plugin/elasticsearch_stats/client.rb', line 58 def url @url end |
#user_agent ⇒ Object (readonly)
Returns the value of attribute user_agent.
58 59 60 |
# File 'lib/fluent/plugin/elasticsearch_stats/client.rb', line 58 def user_agent @user_agent end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
58 59 60 |
# File 'lib/fluent/plugin/elasticsearch_stats/client.rb', line 58 def username @username end |
#verify_ssl ⇒ Object (readonly)
Returns the value of attribute verify_ssl.
58 59 60 |
# File 'lib/fluent/plugin/elasticsearch_stats/client.rb', line 58 def verify_ssl @verify_ssl end |
Instance Method Details
#cluster_health(level: CLUSTER_HEALTH_LEVEL, local: LOCAL) ⇒ Object
75 76 77 78 79 |
# File 'lib/fluent/plugin/elasticsearch_stats/client.rb', line 75 def cluster_health(level: CLUSTER_HEALTH_LEVEL, local: LOCAL) endpoint = '/_cluster/health' params = { level: level, local: local, timeout: "#{timeout}s" } get(endpoint, params) end |
#cluster_stats ⇒ Object
82 83 84 85 86 |
# File 'lib/fluent/plugin/elasticsearch_stats/client.rb', line 82 def cluster_stats endpoint = '/_cluster/stats' params = { timeout: "#{timeout}s" } get(endpoint, params) end |
#dangling ⇒ Object
107 108 109 110 |
# File 'lib/fluent/plugin/elasticsearch_stats/client.rb', line 107 def dangling endpoint = '/_dangling' get(endpoint) end |
#indices_stats(indices: INDICES, level: INDICES_STATS_LEVEL, metrics: nil) ⇒ Object
97 98 99 100 101 102 103 104 |
# File 'lib/fluent/plugin/elasticsearch_stats/client.rb', line 97 def indices_stats(indices: INDICES, level: INDICES_STATS_LEVEL, metrics: nil) indices ||= INDICES endpoint = "/_stats" endpoint = "/#{indices.join(',')}#{endpoint}" if !indices.nil? && !indices.empty? endpoint += "/#{metrics.join(',')}" if metrics&.any? params = { level: level } get(endpoint, params) end |
#nodes_stats(level: NODES_STATS_LEVEL, metrics: nil) ⇒ Object
89 90 91 92 93 94 |
# File 'lib/fluent/plugin/elasticsearch_stats/client.rb', line 89 def nodes_stats(level: NODES_STATS_LEVEL, metrics: nil) endpoint = '/_nodes/stats' endpoint += "/#{metrics.join(',')}" if metrics&.any? params = { level: level, timeout: "#{timeout}s" } get(endpoint, params) end |