Method: Elasticsearch::API::Nodes::Actions#stats

Defined in:
lib/elasticsearch/api/actions/nodes/stats.rb

#stats(arguments = {}) ⇒ Object

Returns statistical information about nodes in the cluster.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :node_id (List)

    A comma-separated list of node IDs or names to limit the returned information; use ‘_local` to return information from the node you’re connecting to, leave empty to get information from all nodes

  • :metric (List)

    Limit the information returned to the specified metrics (options: _all, breaker, fs, http, indices, jvm, os, process, thread_pool, transport, discovery, indexing_pressure)

  • :index_metric (List)

    Limit the information returned for ‘indices` metric to the specific index metrics. Isn’t used if ‘indices` (or `all`) metric isn’t specified. (options: _all, completion, docs, fielddata, query_cache, flush, get, indexing, merge, request_cache, refresh, search, segments, store, warmer, bulk, shard_stats)

  • :completion_fields (List)

    A comma-separated list of fields for the ‘completion` index metric (supports wildcards)

  • :fielddata_fields (List)

    A comma-separated list of fields for the ‘fielddata` index metric (supports wildcards)

  • :fields (List)

    A comma-separated list of fields for ‘fielddata` and `completion` index metric (supports wildcards)

  • :groups (Boolean)

    A comma-separated list of search groups for ‘search` index metric

  • :level (String)

    Return indices stats aggregated at index, node or shard level (options: indices, node, shards)

  • :types (List)

    A comma-separated list of document types for the ‘indexing` index metric

  • :timeout (Time)

    Explicit operation timeout

  • :include_segment_file_sizes (Boolean)

    Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested)

  • :include_unloaded_segments (Boolean)

    If set to true segment stats will include stats for segments that are not currently loaded into memory

  • :headers (Hash)

    Custom HTTP headers

See Also:


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/elasticsearch/api/actions/nodes/stats.rb', line 43

def stats(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'nodes.stats' }

  defined_params = %i[node_id metric index_metric].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _node_id = arguments.delete(:node_id)

  _metric = arguments.delete(:metric)

  _index_metric = arguments.delete(:index_metric)

  method = Elasticsearch::API::HTTP_GET
  path   = if _node_id && _metric && _index_metric
             "_nodes/#{Utils.__listify(_node_id)}/stats/#{Utils.__listify(_metric)}/#{Utils.__listify(_index_metric)}"
           elsif _metric && _index_metric
             "_nodes/stats/#{Utils.__listify(_metric)}/#{Utils.__listify(_index_metric)}"
           elsif _node_id && _metric
             "_nodes/#{Utils.__listify(_node_id)}/stats/#{Utils.__listify(_metric)}"
           elsif _node_id
             "_nodes/#{Utils.__listify(_node_id)}/stats"
           elsif _metric
             "_nodes/stats/#{Utils.__listify(_metric)}"
           else
             '_nodes/stats'
           end
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end