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

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

#stats(arguments = {}) ⇒ Object

Get node statistics. Get statistics for nodes in a cluster. By default, all stats are returned. You can limit the returned information by using metrics.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :node_id (String, Array)

    Comma-separated list of node IDs or names used to limit returned information.

  • :metric (String, Array<String>)

    Limits the information returned to the specific metrics.

  • :index_metric (String, Array<String>)

    Limit the information returned for indices metric to the specific index metrics. It can be used only if indices (or all) metric is specified.

  • :completion_fields (String, Array<String>)

    Comma-separated list or wildcard expressions of fields to include in fielddata and suggest statistics.

  • :fielddata_fields (String, Array<String>)

    Comma-separated list or wildcard expressions of fields to include in fielddata statistics.

  • :fields (String, Array<String>)

    Comma-separated list or wildcard expressions of fields to include in the statistics.

  • :groups (Boolean)

    Comma-separated list of search groups to include in the search statistics.

  • :include_segment_file_sizes (Boolean)

    If true, the call reports the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested).

  • :level (String)

    Indicates whether statistics are aggregated at the node, indices, or shards level. Server default: node.

  • :timeout (Time)

    Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s.

  • :types (Array<String>)

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

  • :include_unloaded_segments (Boolean)

    If true, the response includes information from segments that are not loaded into memory.

  • :error_trace (Boolean)

    When set to true Elasticsearch will include the full stack trace of errors when they occur.

  • :filter_path (String, Array<String>)

    Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch.

  • :human (Boolean)

    When set to true will return statistics in a format suitable for humans. For example ‘“exists_time”: “1h”` for humans and `“exists_time_in_millis”: 3600000` for computers. When disabled the human readable values will be omitted. This makes sense for responses being consumed only by machines.

  • :pretty (Boolean)

    If set to true the returned JSON will be “pretty-formatted”. Only use this option for debugging only.

  • :headers (Hash)

    Custom HTTP headers

See Also:



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
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/elasticsearch/api/actions/nodes/stats.rb', line 56

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

  defined_params = [: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