Class: DatadogAPIClient::V1::LogsAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog_api_client/v1/api/logs_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = DatadogAPIClient::APIClient.default) ⇒ LogsAPI

Returns a new instance of LogsAPI.



22
23
24
# File 'lib/datadog_api_client/v1/api/logs_api.rb', line 22

def initialize(api_client = APIClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



20
21
22
# File 'lib/datadog_api_client/v1/api/logs_api.rb', line 20

def api_client
  @api_client
end

Instance Method Details

#list_logs(body, opts = {}) ⇒ Object

Search logs.



30
31
32
33
# File 'lib/datadog_api_client/v1/api/logs_api.rb', line 30

def list_logs(body, opts = {})
  data, _status_code, _headers = list_logs_with_http_info(body, opts)
  data
end

#list_logs_with_http_info(body, opts = {}) ⇒ Array<(LogsListResponse, Integer, Hash)>

Search logs.

List endpoint returns logs that match a log search query. Results are paginated.

If you are considering archiving logs for your organization, consider use of the Datadog archive capabilities instead of the log list API. See Datadog Logs Archive documentation.

Parameters:

  • body (LogsListRequest)

    Logs filter

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

    the optional parameters

Returns:

  • (Array<(LogsListResponse, Integer, Hash)>)

    LogsListResponse data, response status code and response headers



40
41
42
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/datadog_api_client/v1/api/logs_api.rb', line 40

def list_logs_with_http_info(body, opts = {})

  if @api_client.config.unstable_operations.has_key?(:list_logs)
    unstable_enabled = @api_client.config.unstable_operations[:list_logs]
    if unstable_enabled
      @api_client.config.logger.warn format("Using unstable operation '%s'", "list_logs")
    else
      raise APIError.new(message: format("Unstable operation '%s' is disabled", "list_logs"))
    end
  end

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: LogsAPI.list_logs ...'
  end
  # verify the required parameter 'body' is set
  if @api_client.config.client_side_validation && body.nil?
    fail ArgumentError, "Missing the required parameter 'body' when calling LogsAPI.list_logs"
  end
  # resource path
  local_var_path = '/api/v1/logs-queries/list'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(body)

  # return_type
  return_type = opts[:debug_return_type] || 'LogsListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]

  new_options = opts.merge(
    :operation => :list_logs,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: LogsAPI#list_logs\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#submit_log(body, opts = {}) ⇒ Object

Send logs.



107
108
109
110
# File 'lib/datadog_api_client/v1/api/logs_api.rb', line 107

def submit_log(body, opts = {})
  data, _status_code, _headers = submit_log_with_http_info(body, opts)
  data
end

#submit_log_with_http_info(body, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Deprecated.

This API is deprecated.

Send logs.

Send your logs to your Datadog platform over HTTP. Limits per HTTP request are:

  • Maximum content size per payload (uncompressed): 5MB
  • Maximum size for a single log: 1MB
  • Maximum array size if sending multiple logs in an array: 1000 entries

Any log exceeding 1MB is accepted and truncated by Datadog:

  • For a single log request, the API truncates the log at 1MB and returns a 2xx.
  • For a multi-logs request, the API processes all logs, truncates only logs larger than 1MB, and returns a 2xx.

Datadog recommends sending your logs compressed. Add the Content-Encoding: gzip header to the request when sending compressed logs.

The status codes answered by the HTTP API are:

  • 200: OK
  • 400: Bad request (likely an issue in the payload formatting)
  • 403: Permission issue (likely using an invalid API Key)
  • 413: Payload too large (batch is above 5MB uncompressed)
  • 5xx: Internal error, request should be retried after some time

Parameters:

  • body (Array<HTTPLogItem>)

    Log to send (JSON format).

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

    the optional parameters

Options Hash (opts):

  • :content_encoding (ContentEncoding)

    HTTP header used to compress the media-type.

  • :ddtags (String)

    Log tags can be passed as query parameters with text/plain content type.

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/datadog_api_client/v1/api/logs_api.rb', line 119

def submit_log_with_http_info(body, opts = {})

  if @api_client.config.unstable_operations.has_key?(:submit_log)
    unstable_enabled = @api_client.config.unstable_operations[:submit_log]
    if unstable_enabled
      @api_client.config.logger.warn format("Using unstable operation '%s'", "submit_log")
    else
      raise APIError.new(message: format("Unstable operation '%s' is disabled", "submit_log"))
    end
  end

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: LogsAPI.submit_log ...'
  end
  # verify the required parameter 'body' is set
  if @api_client.config.client_side_validation && body.nil?
    fail ArgumentError, "Missing the required parameter 'body' when calling LogsAPI.submit_log"
  end
  # resource path
  local_var_path = '/v1/input'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'ddtags'] = opts[:'ddtags'] if !opts[:'ddtags'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'application/logplex-1', 'text/plain'])
  header_params['Content-Encoding'] = opts[:'content_encoding'] if !opts[:'content_encoding'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(body)

  # return_type
  return_type = opts[:debug_return_type] || 'Object'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth]

  new_options = opts.merge(
    :operation => :submit_log,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: LogsAPI#submit_log\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end