class DatadogAPIClient::V1::MetricsAPI

Attributes

api_client[RW]

Public Class Methods

new(api_client = APIClient.default) click to toggle source
# File lib/datadog_api_client/v1/api/metrics_api.rb, line 22
def initialize(api_client = APIClient.default)
  @api_client = api_client
end

Public Instance Methods

get_metric_metadata(metric_name, opts = {}) click to toggle source

Get metric metadata Get metadata about a specific metric. @param metric_name [String] Name of the metric for which to get metadata. @param [Hash] opts the optional parameters @return [MetricMetadata]

# File lib/datadog_api_client/v1/api/metrics_api.rb, line 30
def get_metric_metadata(metric_name, opts = {})
  data, _status_code, _headers = get_metric_metadata_with_http_info(metric_name, opts)
  data
end
get_metric_metadata_with_http_info(metric_name, opts = {}) click to toggle source

Get metric metadata Get metadata about a specific metric. @param metric_name [String] Name of the metric for which to get metadata. @param [Hash] opts the optional parameters @return [Array<(MetricMetadata, Integer, Hash)>] MetricMetadata data, response status code and response headers

# File lib/datadog_api_client/v1/api/metrics_api.rb, line 40
def get_metric_metadata_with_http_info(metric_name, opts = {})

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

  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))

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

  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
  )

  data, status_code, headers = @api_client.call_api(: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 = {}) click to toggle source

Get active metrics list Get the list of actively reporting metrics from a given time until now. @param from [Integer] Seconds since the Unix epoch. @param [Hash] opts the optional parameters @option opts [String] :host Hostname for filtering the list of metrics returned. If set, metrics retrieved are those with the corresponding hostname tag. @option opts [String] :tag_filter Filter metrics that have been submitted with the given tags. Supports boolean and wildcard expressions. Cannot be combined with other filters. @return [MetricsListResponse]

# File lib/datadog_api_client/v1/api/metrics_api.rb, line 105
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 = {}) click to toggle source

Get active metrics list Get the list of actively reporting metrics from a given time until now. @param from [Integer] Seconds since the Unix epoch. @param [Hash] opts the optional parameters @option opts [String] :host Hostname for filtering the list of metrics returned. If set, metrics retrieved are those with the corresponding hostname tag. @option opts [String] :tag_filter Filter metrics that have been submitted with the given tags. Supports boolean and wildcard expressions. Cannot be combined with other filters. @return [Array<(MetricsListResponse, Integer, Hash)>] MetricsListResponse data, response status code and response headers

# File lib/datadog_api_client/v1/api/metrics_api.rb, line 117
def list_active_metrics_with_http_info(from, opts = {})

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

  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]

  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
  )

  data, status_code, headers = @api_client.call_api(: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 = {}) click to toggle source

Search metrics Search for metrics from the last 24 hours in Datadog. @param q [String] Query string to search metrics upon. Must be prefixed with &#x60;metrics:&#x60;. @param [Hash] opts the optional parameters @return [MetricSearchResponse]

# File lib/datadog_api_client/v1/api/metrics_api.rb, line 183
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 = {}) click to toggle source

Search metrics Search for metrics from the last 24 hours in Datadog. @param q [String] Query string to search metrics upon. Must be prefixed with &#x60;metrics:&#x60;. @param [Hash] opts the optional parameters @return [Array<(MetricSearchResponse, Integer, Hash)>] MetricSearchResponse data, response status code and response headers

# File lib/datadog_api_client/v1/api/metrics_api.rb, line 193
def list_metrics_with_http_info(q, opts = {})

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

  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]

  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
  )

  data, status_code, headers = @api_client.call_api(: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 = {}) click to toggle source

Query timeseries points Query timeseries points. @param from [Integer] Start of the queried time period, seconds since the Unix epoch. @param to [Integer] End of the queried time period, seconds since the Unix epoch. @param query [String] Query string. @param [Hash] opts the optional parameters @return [MetricsQueryResponse]

# File lib/datadog_api_client/v1/api/metrics_api.rb, line 259
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 = {}) click to toggle source

Query timeseries points Query timeseries points. @param from [Integer] Start of the queried time period, seconds since the Unix epoch. @param to [Integer] End of the queried time period, seconds since the Unix epoch. @param query [String] Query string. @param [Hash] opts the optional parameters @return [Array<(MetricsQueryResponse, Integer, Hash)>] MetricsQueryResponse data, response status code and response headers

# File lib/datadog_api_client/v1/api/metrics_api.rb, line 271
def query_metrics_with_http_info(from, to, query, opts = {})

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

  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]

  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
  )

  data, status_code, headers = @api_client.call_api(: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_metrics(body, opts = {}) click to toggle source

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 - 32 bits for the value - 20 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. @param body [MetricsPayload] @param [Hash] opts the optional parameters @return [IntakePayloadAccepted]

# File lib/datadog_api_client/v1/api/metrics_api.rb, line 345
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 = {}) click to toggle source

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 - 32 bits for the value - 20 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. @param body [MetricsPayload] @param [Hash] opts the optional parameters @return [Array<(IntakePayloadAccepted, Integer, Hash)>] IntakePayloadAccepted data, response status code and response headers

# File lib/datadog_api_client/v1/api/metrics_api.rb, line 355
def submit_metrics_with_http_info(body, opts = {})

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

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: MetricsAPI.submit_metrics ...'
  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(['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] || '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
  )

  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: 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 = {}) click to toggle source

Edit metric metadata Edit metadata of a specific metric. Find out more about [supported types](docs.datadoghq.com/developers/metrics). @param metric_name [String] Name of the metric for which to edit metadata. @param body [MetricMetadata] New metadata. @param [Hash] opts the optional parameters @return [MetricMetadata]

# File lib/datadog_api_client/v1/api/metrics_api.rb, line 421
def update_metric_metadata(metric_name, body, opts = {})
  data, _status_code, _headers = update_metric_metadata_with_http_info(metric_name, body, opts)
  data
end
update_metric_metadata_with_http_info(metric_name, body, opts = {}) click to toggle source

Edit metric metadata Edit metadata of a specific metric. Find out more about [supported types](docs.datadoghq.com/developers/metrics). @param metric_name [String] Name of the metric for which to edit metadata. @param body [MetricMetadata] New metadata. @param [Hash] opts the optional parameters @return [Array<(MetricMetadata, Integer, Hash)>] MetricMetadata data, response status code and response headers

# File lib/datadog_api_client/v1/api/metrics_api.rb, line 432
def update_metric_metadata_with_http_info(metric_name, body, opts = {})

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

  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))

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

  data, status_code, headers = @api_client.call_api(: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