Module: Elasticsearch::XPack::API::Monitoring::Actions

Included in:
MonitoringClient
Defined in:
lib/elasticsearch/xpack/api/namespace/monitoring.rb,
lib/elasticsearch/xpack/api/actions/monitoring/bulk.rb

Instance Method Summary collapse

Instance Method Details

#bulk(arguments = {}) ⇒ Object

Insert monitoring data in bulk

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :type (String)

    Default document type for items which don’t provide one

  • :body (Hash)

    The operation definition and data (action-data pairs), separated by newlines (Required)

  • :system_id (String)

    Identifier of the monitored system

  • :system_api_version (String)

    API version of the monitored system

  • :system_version (String)

    Version of the monitored system

Raises:

  • (ArgumentError)

See Also:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/elasticsearch/xpack/api/actions/monitoring/bulk.rb', line 34

def bulk(arguments={})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  valid_params = [
    :system_id,
    :system_api_version,
    :system_version,
    :interval ]

  arguments = arguments.clone
  type = arguments.delete(:type)
  body = arguments.delete(:body)

  method = Elasticsearch::API::HTTP_POST
  path   = Elasticsearch::API::Utils.__pathify '_xpack/monitoring', type, '_bulk'
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, valid_params

  if body.is_a? Array
    payload = Elasticsearch::API::Utils.__bulkify(body)
  else
    payload = body
  end

  perform_request(method, path, params, payload).body
end