Class: DatadogAPIClient::V1::MetricsAPI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of MetricsAPI.



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

def initialize(api_client = DatadogAPIClient::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/metrics_api.rb', line 20

def api_client
  @api_client
end

Instance Method Details

#get_metric_metadata(metric_name, opts = {}) ⇒ Object

Get metric metadata.



29
30
31
32
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 29

def (metric_name, opts = {})
  data, _status_code, _headers = (metric_name, opts)
  data
end

#get_metric_metadata_with_http_info(metric_name, opts = {}) ⇒ Array<(MetricMetadata, Integer, Hash)>

Get metric metadata.

Get metadata about a specific metric.

Parameters:

  • metric_name (String)

    Name of the metric for which to get metadata.

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

    the optional parameters

Returns:

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

    MetricMetadata data, response status code and response headers



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
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 41

def (metric_name, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsAPI.get_metric_metadata ...'
  end
  # verify the required parameter 'metric_name' is set
  if @api_client.config.client_side_validation && metric_name.nil?
    fail ArgumentError, "Missing the required parameter 'metric_name' when calling MetricsAPI.get_metric_metadata"
  end
  # resource path
  local_var_path = '/api/v1/metrics/{metric_name}'.sub('{metric_name}', CGI.escape(metric_name.to_s).gsub('%2F', '/'))

  # 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'])

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

  # http body (model)
  post_body = opts[:debug_body]

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

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

  new_options = opts.merge(
    :operation => :get_metric_metadata,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

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

#list_active_metrics(from, opts = {}) ⇒ Object

Get active metrics list.



94
95
96
97
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 94

def list_active_metrics(from, opts = {})
  data, _status_code, _headers = list_active_metrics_with_http_info(from, opts)
  data
end

#list_active_metrics_with_http_info(from, opts = {}) ⇒ Array<(MetricsListResponse, Integer, Hash)>

Get active metrics list.

Get the list of actively reporting metrics from a given time until now.

Parameters:

  • from (Integer)

    Seconds since the Unix epoch.

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

    the optional parameters

Options Hash (opts):

  • :host (String)

    Hostname for filtering the list of metrics returned. If set, metrics retrieved are those with the corresponding hostname tag.

  • :tag_filter (String)

    Filter metrics that have been submitted with the given tags. Supports boolean and wildcard expressions. Cannot be combined with other filters.

Returns:

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

    MetricsListResponse data, response status code and response headers



108
109
110
111
112
113
114
115
116
117
118
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
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 108

def list_active_metrics_with_http_info(from, opts = {})

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

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

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

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

  # http body (model)
  post_body = opts[:debug_body]

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

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

  new_options = opts.merge(
    :operation => :list_active_metrics,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

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

#list_metrics(q, opts = {}) ⇒ Object

Search metrics.



164
165
166
167
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 164

def list_metrics(q, opts = {})
  data, _status_code, _headers = list_metrics_with_http_info(q, opts)
  data
end

#list_metrics_with_http_info(q, opts = {}) ⇒ Array<(MetricSearchResponse, Integer, Hash)>

Search metrics.

Search for metrics from the last 24 hours in Datadog.

Parameters:

  • q (String)

    Query string to search metrics upon. Can optionally be prefixed with ‘metrics:`.

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

    the optional parameters

Returns:

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

    MetricSearchResponse data, response status code and response headers



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 176

def list_metrics_with_http_info(q, opts = {})

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

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

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

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

  # http body (model)
  post_body = opts[:debug_body]

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

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

  new_options = opts.merge(
    :operation => :list_metrics,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

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

#query_metrics(from, to, query, opts = {}) ⇒ Object

Query timeseries points.



230
231
232
233
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 230

def query_metrics(from, to, query, opts = {})
  data, _status_code, _headers = query_metrics_with_http_info(from, to, query, opts)
  data
end

#query_metrics_with_http_info(from, to, query, opts = {}) ⇒ Array<(MetricsQueryResponse, Integer, Hash)>

Query timeseries points.

Query timeseries points.

Parameters:

  • from (Integer)

    Start of the queried time period, seconds since the Unix epoch.

  • to (Integer)

    End of the queried time period, seconds since the Unix epoch.

  • query (String)

    Query string.

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

    the optional parameters

Returns:

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

    MetricsQueryResponse data, response status code and response headers



244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 244

def query_metrics_with_http_info(from, to, query, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsAPI.query_metrics ...'
  end
  # verify the required parameter 'from' is set
  if @api_client.config.client_side_validation && from.nil?
    fail ArgumentError, "Missing the required parameter 'from' when calling MetricsAPI.query_metrics"
  end
  # verify the required parameter 'to' is set
  if @api_client.config.client_side_validation && to.nil?
    fail ArgumentError, "Missing the required parameter 'to' when calling MetricsAPI.query_metrics"
  end
  # verify the required parameter 'query' is set
  if @api_client.config.client_side_validation && query.nil?
    fail ArgumentError, "Missing the required parameter 'query' when calling MetricsAPI.query_metrics"
  end
  # resource path
  local_var_path = '/api/v1/query'

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

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

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

  # http body (model)
  post_body = opts[:debug_body]

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

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

  new_options = opts.merge(
    :operation => :query_metrics,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

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

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

Submit distribution points.



308
309
310
311
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 308

def submit_distribution_points(body, opts = {})
  data, _status_code, _headers = submit_distribution_points_with_http_info(body, opts)
  data
end

#submit_distribution_points_with_http_info(body, opts = {}) ⇒ Array<(IntakePayloadAccepted, Integer, Hash)>

Submit distribution points.

The distribution points end-point allows you to post distribution data that can be graphed on Datadog’s dashboards.

Parameters:

Options Hash (opts):

Returns:

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

    IntakePayloadAccepted data, response status code and response headers



321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 321

def submit_distribution_points_with_http_info(body, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsAPI.submit_distribution_points ...'
  end
  allowable_values = ['deflate']
  if @api_client.config.client_side_validation && opts[:'content_encoding'] && !allowable_values.include?(opts[:'content_encoding'])
    fail ArgumentError, "invalid value for \"content_encoding\", must be one of #{allowable_values}"
  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 MetricsAPI.submit_distribution_points"
  end
  # resource path
  local_var_path = '/api/v1/distribution_points'

  # 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(['text/json', 'application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['text/json'])
  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] || 'IntakePayloadAccepted'

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

  new_options = opts.merge(
    :operation => :submit_distribution_points,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

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

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

Submit metrics.



381
382
383
384
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 381

def submit_metrics(body, opts = {})
  data, _status_code, _headers = submit_metrics_with_http_info(body, opts)
  data
end

#submit_metrics_with_http_info(body, opts = {}) ⇒ Array<(IntakePayloadAccepted, Integer, Hash)>

Submit metrics.

The metrics end-point allows you to post time-series data that can be graphed on Datadog’s dashboards. The maximum payload size is 3.2 megabytes (3200000 bytes). Compressed payloads must have a decompressed size of less than 62 megabytes (62914560 bytes).

If you’re submitting metrics directly to the Datadog API without using DogStatsD, expect:

  • 64 bits for the timestamp

  • 64 bits for the value

  • 40 bytes for the metric names

  • 50 bytes for the timeseries

  • The full payload is approximately 100 bytes. However, with the DogStatsD API,

compression is applied, which reduces the payload size.

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:

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

    IntakePayloadAccepted data, response status code and response headers



404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 404

def submit_metrics_with_http_info(body, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsAPI.submit_metrics ...'
  end
  allowable_values = ['deflate', 'gzip']
  if @api_client.config.client_side_validation && opts[:'content_encoding'] && !allowable_values.include?(opts[:'content_encoding'])
    fail ArgumentError, "invalid value for \"content_encoding\", must be one of #{allowable_values}"
  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 MetricsAPI.submit_metrics"
  end
  # resource path
  local_var_path = '/api/v1/series'

  # 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(['text/json', 'application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['text/json'])
  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] || 'IntakePayloadAccepted'

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

  new_options = opts.merge(
    :operation => :submit_metrics,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

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

#update_metric_metadata(metric_name, body, opts = {}) ⇒ Object

Edit metric metadata.



464
465
466
467
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 464

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

#update_metric_metadata_with_http_info(metric_name, body, opts = {}) ⇒ Array<(MetricMetadata, Integer, Hash)>

Edit metric metadata.

Edit metadata of a specific metric. Find out more about [supported types](docs.datadoghq.com/developers/metrics).

Parameters:

  • metric_name (String)

    Name of the metric for which to edit metadata.

  • body (MetricMetadata)

    New metadata.

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

    the optional parameters

Returns:

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

    MetricMetadata data, response status code and response headers



477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
# File 'lib/datadog_api_client/v1/api/metrics_api.rb', line 477

def (metric_name, body, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsAPI.update_metric_metadata ...'
  end
  # verify the required parameter 'metric_name' is set
  if @api_client.config.client_side_validation && metric_name.nil?
    fail ArgumentError, "Missing the required parameter 'metric_name' when calling MetricsAPI.update_metric_metadata"
  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 MetricsAPI.update_metric_metadata"
  end
  # resource path
  local_var_path = '/api/v1/metrics/{metric_name}'.sub('{metric_name}', CGI.escape(metric_name.to_s).gsub('%2F', '/'))

  # 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] || 'MetricMetadata'

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

  new_options = opts.merge(
    :operation => :update_metric_metadata,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

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