=begin #Datadog API V2 Collection #Collection of all Datadog Public endpoints. The version of the OpenAPI document: 1.0 Contact: support@datadoghq.com Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2020-Present Datadog, Inc. =end require 'cgi' module DatadogAPIClient::V2 class MetricsAPI attr_accessor :api_client def initialize(api_client = DatadogAPIClient::APIClient.default) @api_client = api_client end # Configure tags for multiple metrics. # # @see #create_bulk_tags_metrics_configuration_with_http_info def create_bulk_tags_metrics_configuration(body, opts = {}) data, _status_code, _headers = create_bulk_tags_metrics_configuration_with_http_info(body, opts) data end # Configure tags for multiple metrics. # # Create and define a list of queryable tag keys for a set of existing count, gauge, rate, and distribution metrics. # Metrics are selected by passing a metric name prefix. Use the Delete method of this API path to remove tag configurations. # Results can be sent to a set of account email addresses, just like the same operation in the Datadog web app. # If multiple calls include the same metric, the last configuration applied (not by submit order) is used, do not # expect deterministic ordering of concurrent calls. The `exclude_tags_mode` value will set all metrics that match the prefix to # the same exclusion state, metric tag configurations do not support mixed inclusion and exclusion for tags on the same metric. # Can only be used with application keys of users with the `Manage Tags for Metrics` permission. # # @param body [MetricBulkTagConfigCreateRequest] # @param opts [Hash] the optional parameters # @return [Array<(MetricBulkTagConfigResponse, Integer, Hash)>] MetricBulkTagConfigResponse data, response status code and response headers def create_bulk_tags_metrics_configuration_with_http_info(body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.create_bulk_tags_metrics_configuration ...' 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.create_bulk_tags_metrics_configuration" end # resource path local_var_path = '/api/v2/metrics/config/bulk-tags' # 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] || 'MetricBulkTagConfigResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] new_options = opts.merge( :operation => :create_bulk_tags_metrics_configuration, :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 => "V2" ) 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#create_bulk_tags_metrics_configuration\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create a tag configuration. # # @see #create_tag_configuration_with_http_info def create_tag_configuration(metric_name, body, opts = {}) data, _status_code, _headers = create_tag_configuration_with_http_info(metric_name, body, opts) data end # Create a tag configuration. # # Create and define a list of queryable tag keys for an existing count/gauge/rate/distribution metric. # Optionally, include percentile aggregations on any distribution metric or configure custom aggregations # on any count, rate, or gauge metric. By setting `exclude_tags_mode` to true the behavior is changed # from an allow-list to a deny-list, and tags in the defined list will not be queryable. # Can only be used with application keys of users with the `Manage Tags for Metrics` permission. # # @param metric_name [String] The name of the metric. # @param body [MetricTagConfigurationCreateRequest] # @param opts [Hash] the optional parameters # @return [Array<(MetricTagConfigurationResponse, Integer, Hash)>] MetricTagConfigurationResponse data, response status code and response headers def create_tag_configuration_with_http_info(metric_name, body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.create_tag_configuration ...' 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.create_tag_configuration" 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.create_tag_configuration" end # resource path local_var_path = '/api/v2/metrics/{metric_name}/tags'.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] || 'MetricTagConfigurationResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] new_options = opts.merge( :operation => :create_tag_configuration, :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 => "V2" ) 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#create_tag_configuration\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete tags for multiple metrics. # # @see #delete_bulk_tags_metrics_configuration_with_http_info def delete_bulk_tags_metrics_configuration(body, opts = {}) data, _status_code, _headers = delete_bulk_tags_metrics_configuration_with_http_info(body, opts) data end # Delete tags for multiple metrics. # # Delete all custom lists of queryable tag keys for a set of existing count, gauge, rate, and distribution metrics. # Metrics are selected by passing a metric name prefix. # Results can be sent to a set of account email addresses, just like the same operation in the Datadog web app. # Can only be used with application keys of users with the `Manage Tags for Metrics` permission. # # @param body [MetricBulkTagConfigDeleteRequest] # @param opts [Hash] the optional parameters # @return [Array<(MetricBulkTagConfigResponse, Integer, Hash)>] MetricBulkTagConfigResponse data, response status code and response headers def delete_bulk_tags_metrics_configuration_with_http_info(body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.delete_bulk_tags_metrics_configuration ...' 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.delete_bulk_tags_metrics_configuration" end # resource path local_var_path = '/api/v2/metrics/config/bulk-tags' # 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] || 'MetricBulkTagConfigResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] new_options = opts.merge( :operation => :delete_bulk_tags_metrics_configuration, :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 => "V2" ) data, status_code, headers = @api_client.call_api(Net::HTTP::Delete, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsAPI#delete_bulk_tags_metrics_configuration\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete a tag configuration. # # @see #delete_tag_configuration_with_http_info def delete_tag_configuration(metric_name, opts = {}) delete_tag_configuration_with_http_info(metric_name, opts) nil end # Delete a tag configuration. # # Deletes a metric's tag configuration. Can only be used with application # keys from users with the `Manage Tags for Metrics` permission. # # @param metric_name [String] The name of the metric. # @param opts [Hash] the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def delete_tag_configuration_with_http_info(metric_name, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.delete_tag_configuration ...' 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.delete_tag_configuration" end # resource path local_var_path = '/api/v2/metrics/{metric_name}/tags'.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(['*/*']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] new_options = opts.merge( :operation => :delete_tag_configuration, :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 => "V2" ) data, status_code, headers = @api_client.call_api(Net::HTTP::Delete, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsAPI#delete_tag_configuration\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Tag Configuration Cardinality Estimator. # # @see #estimate_metrics_output_series_with_http_info def estimate_metrics_output_series(metric_name, opts = {}) data, _status_code, _headers = estimate_metrics_output_series_with_http_info(metric_name, opts) data end # Tag Configuration Cardinality Estimator. # # Returns the estimated cardinality for a metric with a given tag, percentile and number of aggregations configuration using Metrics without Limits™. # # @param metric_name [String] The name of the metric. # @param opts [Hash] the optional parameters # @option opts [String] :filter_groups Filtered tag keys that the metric is configured to query with. # @option opts [Integer] :filter_hours_ago The number of hours of look back (from now) to estimate cardinality with. If unspecified, it defaults to 0 hours. # @option opts [Integer] :filter_num_aggregations The number of aggregations that a `count`, `rate`, or `gauge` metric is configured to use. Max number of aggregation combos is 9. # @option opts [Boolean] :filter_pct A boolean, for distribution metrics only, to estimate cardinality if the metric includes additional percentile aggregators. # @option opts [Integer] :filter_timespan_h A window, in hours, from the look back to estimate cardinality with. The minimum and default is 1 hour. # @return [Array<(MetricEstimateResponse, Integer, Hash)>] MetricEstimateResponse data, response status code and response headers def estimate_metrics_output_series_with_http_info(metric_name, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.estimate_metrics_output_series ...' 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.estimate_metrics_output_series" end if @api_client.config.client_side_validation && !opts[:'filter_hours_ago'].nil? && opts[:'filter_hours_ago'] > 2147483647 fail ArgumentError, 'invalid value for "opts[:"filter_hours_ago"]" when calling MetricsAPI.estimate_metrics_output_series, must be smaller than or equal to 2147483647.' end if @api_client.config.client_side_validation && !opts[:'filter_hours_ago'].nil? && opts[:'filter_hours_ago'] < 49 fail ArgumentError, 'invalid value for "opts[:"filter_hours_ago"]" when calling MetricsAPI.estimate_metrics_output_series, must be greater than or equal to 49.' end if @api_client.config.client_side_validation && !opts[:'filter_num_aggregations'].nil? && opts[:'filter_num_aggregations'] > 9 fail ArgumentError, 'invalid value for "opts[:"filter_num_aggregations"]" when calling MetricsAPI.estimate_metrics_output_series, must be smaller than or equal to 9.' end if @api_client.config.client_side_validation && !opts[:'filter_timespan_h'].nil? && opts[:'filter_timespan_h'] > 2147483647 fail ArgumentError, 'invalid value for "opts[:"filter_timespan_h"]" when calling MetricsAPI.estimate_metrics_output_series, must be smaller than or equal to 2147483647.' end # resource path local_var_path = '/api/v2/metrics/{metric_name}/estimate'.sub('{metric_name}', CGI.escape(metric_name.to_s).gsub('%2F', '/')) # query parameters query_params = opts[:query_params] || {} query_params[:'filter[groups]'] = opts[:'filter_groups'] if !opts[:'filter_groups'].nil? query_params[:'filter[hours_ago]'] = opts[:'filter_hours_ago'] if !opts[:'filter_hours_ago'].nil? query_params[:'filter[num_aggregations]'] = opts[:'filter_num_aggregations'] if !opts[:'filter_num_aggregations'].nil? query_params[:'filter[pct]'] = opts[:'filter_pct'] if !opts[:'filter_pct'].nil? query_params[:'filter[timespan_h]'] = opts[:'filter_timespan_h'] if !opts[:'filter_timespan_h'].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] || 'MetricEstimateResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] new_options = opts.merge( :operation => :estimate_metrics_output_series, :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 => "V2" ) 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#estimate_metrics_output_series\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List active tags and aggregations. # # @see #list_active_metric_configurations_with_http_info def list_active_metric_configurations(metric_name, opts = {}) data, _status_code, _headers = list_active_metric_configurations_with_http_info(metric_name, opts) data end # List active tags and aggregations. # # List tags and aggregations that are actively queried on dashboards, notebooks, monitors, and the Metrics Explorer for a given metric name. # # @param metric_name [String] The name of the metric. # @param opts [Hash] the optional parameters # @option opts [Integer] :window_seconds The number of seconds of look back (from now). Default value is 604,800 (1 week), minimum value is 7200 (2 hours), maximum value is 2,630,000 (1 month). # @return [Array<(MetricSuggestedTagsAndAggregationsResponse, Integer, Hash)>] MetricSuggestedTagsAndAggregationsResponse data, response status code and response headers def list_active_metric_configurations_with_http_info(metric_name, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.list_active_metric_configurations ...' 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.list_active_metric_configurations" end # resource path local_var_path = '/api/v2/metrics/{metric_name}/active-configurations'.sub('{metric_name}', CGI.escape(metric_name.to_s).gsub('%2F', '/')) # query parameters query_params = opts[:query_params] || {} query_params[:'window[seconds]'] = opts[:'window_seconds'] if !opts[:'window_seconds'].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] || 'MetricSuggestedTagsAndAggregationsResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] new_options = opts.merge( :operation => :list_active_metric_configurations, :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 => "V2" ) 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_metric_configurations\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Related Assets to a Metric. # # @see #list_metric_assets_with_http_info def list_metric_assets(metric_name, opts = {}) data, _status_code, _headers = list_metric_assets_with_http_info(metric_name, opts) data end # Related Assets to a Metric. # # Returns dashboards, monitors, notebooks, and SLOs that a metric is stored in, if any. Updated every 24 hours. # # @param metric_name [String] The name of the metric. # @param opts [Hash] the optional parameters # @return [Array<(MetricAssetsResponse, Integer, Hash)>] MetricAssetsResponse data, response status code and response headers def list_metric_assets_with_http_info(metric_name, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.list_metric_assets ...' 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.list_metric_assets" end # resource path local_var_path = '/api/v2/metrics/{metric_name}/assets'.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] || 'MetricAssetsResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] new_options = opts.merge( :operation => :list_metric_assets, :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 => "V2" ) 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_metric_assets\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List tag configuration by name. # # @see #list_tag_configuration_by_name_with_http_info def list_tag_configuration_by_name(metric_name, opts = {}) data, _status_code, _headers = list_tag_configuration_by_name_with_http_info(metric_name, opts) data end # List tag configuration by name. # # Returns the tag configuration for the given metric name. # # @param metric_name [String] The name of the metric. # @param opts [Hash] the optional parameters # @return [Array<(MetricTagConfigurationResponse, Integer, Hash)>] MetricTagConfigurationResponse data, response status code and response headers def list_tag_configuration_by_name_with_http_info(metric_name, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.list_tag_configuration_by_name ...' 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.list_tag_configuration_by_name" end # resource path local_var_path = '/api/v2/metrics/{metric_name}/tags'.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] || 'MetricTagConfigurationResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] new_options = opts.merge( :operation => :list_tag_configuration_by_name, :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 => "V2" ) 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_tag_configuration_by_name\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get a list of metrics. # # @see #list_tag_configurations_with_http_info def list_tag_configurations(opts = {}) data, _status_code, _headers = list_tag_configurations_with_http_info(opts) data end # Get a list of metrics. # # Returns all metrics that can be configured in the Metrics Summary page or with Metrics without Limits™ (matching additional filters if specified). # # @param opts [Hash] the optional parameters # @option opts [Boolean] :filter_configured Filter custom metrics that have configured tags. # @option opts [String] :filter_tags_configured Filter tag configurations by configured tags. # @option opts [MetricTagConfigurationMetricTypeCategory] :filter_metric_type Filter metrics by metric type. # @option opts [Boolean] :filter_include_percentiles Filter distributions with additional percentile aggregations enabled or disabled. # @option opts [Boolean] :filter_queried (Beta) Filter custom metrics that have or have not been queried in the specified window[seconds]. If no window is provided or the window is less than 2 hours, a default of 2 hours will be applied. # @option opts [String] :filter_tags Filter metrics that have been submitted with the given tags. Supports boolean and wildcard expressions. Can only be combined with the filter[queried] filter. # @option opts [Integer] :window_seconds The number of seconds of look back (from now) to apply to a filter[tag] or filter[queried] query. Default value is 3600 (1 hour), maximum value is 2,592,000 (30 days). # @return [Array<(MetricsAndMetricTagConfigurationsResponse, Integer, Hash)>] MetricsAndMetricTagConfigurationsResponse data, response status code and response headers def list_tag_configurations_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.list_tag_configurations ...' end allowable_values = ['non_distribution', 'distribution'] if @api_client.config.client_side_validation && opts[:'filter_metric_type'] && !allowable_values.include?(opts[:'filter_metric_type']) fail ArgumentError, "invalid value for \"filter_metric_type\", must be one of #{allowable_values}" end # resource path local_var_path = '/api/v2/metrics' # query parameters query_params = opts[:query_params] || {} query_params[:'filter[configured]'] = opts[:'filter_configured'] if !opts[:'filter_configured'].nil? query_params[:'filter[tags_configured]'] = opts[:'filter_tags_configured'] if !opts[:'filter_tags_configured'].nil? query_params[:'filter[metric_type]'] = opts[:'filter_metric_type'] if !opts[:'filter_metric_type'].nil? query_params[:'filter[include_percentiles]'] = opts[:'filter_include_percentiles'] if !opts[:'filter_include_percentiles'].nil? query_params[:'filter[queried]'] = opts[:'filter_queried'] if !opts[:'filter_queried'].nil? query_params[:'filter[tags]'] = opts[:'filter_tags'] if !opts[:'filter_tags'].nil? query_params[:'window[seconds]'] = opts[:'window_seconds'] if !opts[:'window_seconds'].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] || 'MetricsAndMetricTagConfigurationsResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] new_options = opts.merge( :operation => :list_tag_configurations, :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 => "V2" ) 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_tag_configurations\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List tags by metric name. # # @see #list_tags_by_metric_name_with_http_info def list_tags_by_metric_name(metric_name, opts = {}) data, _status_code, _headers = list_tags_by_metric_name_with_http_info(metric_name, opts) data end # List tags by metric name. # # View indexed tag key-value pairs for a given metric name over the previous hour. # # @param metric_name [String] The name of the metric. # @param opts [Hash] the optional parameters # @return [Array<(MetricAllTagsResponse, Integer, Hash)>] MetricAllTagsResponse data, response status code and response headers def list_tags_by_metric_name_with_http_info(metric_name, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.list_tags_by_metric_name ...' 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.list_tags_by_metric_name" end # resource path local_var_path = '/api/v2/metrics/{metric_name}/all-tags'.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] || 'MetricAllTagsResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] new_options = opts.merge( :operation => :list_tags_by_metric_name, :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 => "V2" ) 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_tags_by_metric_name\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List distinct metric volumes by metric name. # # @see #list_volumes_by_metric_name_with_http_info def list_volumes_by_metric_name(metric_name, opts = {}) data, _status_code, _headers = list_volumes_by_metric_name_with_http_info(metric_name, opts) data end # List distinct metric volumes by metric name. # # View distinct metrics volumes for the given metric name. # # Custom metrics generated in-app from other products will return `null` for ingested volumes. # # @param metric_name [String] The name of the metric. # @param opts [Hash] the optional parameters # @return [Array<(MetricVolumesResponse, Integer, Hash)>] MetricVolumesResponse data, response status code and response headers def list_volumes_by_metric_name_with_http_info(metric_name, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.list_volumes_by_metric_name ...' 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.list_volumes_by_metric_name" end # resource path local_var_path = '/api/v2/metrics/{metric_name}/volumes'.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] || 'MetricVolumesResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] new_options = opts.merge( :operation => :list_volumes_by_metric_name, :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 => "V2" ) 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_volumes_by_metric_name\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Query scalar data across multiple products. # # @see #query_scalar_data_with_http_info def query_scalar_data(body, opts = {}) data, _status_code, _headers = query_scalar_data_with_http_info(body, opts) data end # Query scalar data across multiple products. # # Query scalar values (as seen on Query Value, Table, and Toplist widgets). # Multiple data sources are supported with the ability to # process the data using formulas and functions. # # @param body [ScalarFormulaQueryRequest] # @param opts [Hash] the optional parameters # @return [Array<(ScalarFormulaQueryResponse, Integer, Hash)>] ScalarFormulaQueryResponse data, response status code and response headers def query_scalar_data_with_http_info(body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.query_scalar_data ...' 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.query_scalar_data" end # resource path local_var_path = '/api/v2/query/scalar' # 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] || 'ScalarFormulaQueryResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] new_options = opts.merge( :operation => :query_scalar_data, :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 => "V2" ) 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#query_scalar_data\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Query timeseries data across multiple products. # # @see #query_timeseries_data_with_http_info def query_timeseries_data(body, opts = {}) data, _status_code, _headers = query_timeseries_data_with_http_info(body, opts) data end # Query timeseries data across multiple products. # # Query timeseries data across various data sources and # process the data by applying formulas and functions. # # @param body [TimeseriesFormulaQueryRequest] # @param opts [Hash] the optional parameters # @return [Array<(TimeseriesFormulaQueryResponse, Integer, Hash)>] TimeseriesFormulaQueryResponse data, response status code and response headers def query_timeseries_data_with_http_info(body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.query_timeseries_data ...' 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.query_timeseries_data" end # resource path local_var_path = '/api/v2/query/timeseries' # 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] || 'TimeseriesFormulaQueryResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] new_options = opts.merge( :operation => :query_timeseries_data, :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 => "V2" ) 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#query_timeseries_data\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Submit metrics. # # @see #submit_metrics_with_http_info def submit_metrics(body, opts = {}) data, _status_code, _headers = submit_metrics_with_http_info(body, opts) data end # 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 500 kilobytes (512000 bytes). Compressed payloads must have a decompressed size of less than 5 megabytes (5242880 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 # - 20 bytes for the metric names # - 50 bytes for the timeseries # - The full payload is approximately 100 bytes. # # Host name is one of the resources in the Resources field. # # @param body [MetricPayload] # @param opts [Hash] the optional parameters # @option opts [MetricContentEncoding] :content_encoding HTTP header used to compress the media-type. # @return [Array<(IntakePayloadAccepted, Integer, Hash)>] IntakePayloadAccepted data, response status code and response headers 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', 'zstd1', '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/v2/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']) 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 => "V2" ) 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 a tag configuration. # # @see #update_tag_configuration_with_http_info def update_tag_configuration(metric_name, body, opts = {}) data, _status_code, _headers = update_tag_configuration_with_http_info(metric_name, body, opts) data end # Update a tag configuration. # # Update the tag configuration of a metric or percentile aggregations of a distribution metric or custom aggregations # of a count, rate, or gauge metric. By setting `exclude_tags_mode` to true the behavior is changed # from an allow-list to a deny-list, and tags in the defined list will not be queryable. # Can only be used with application keys from users with the `Manage Tags for Metrics` permission. This endpoint requires # a tag configuration to be created first. # # @param metric_name [String] The name of the metric. # @param body [MetricTagConfigurationUpdateRequest] # @param opts [Hash] the optional parameters # @return [Array<(MetricTagConfigurationResponse, Integer, Hash)>] MetricTagConfigurationResponse data, response status code and response headers def update_tag_configuration_with_http_info(metric_name, body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsAPI.update_tag_configuration ...' 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_tag_configuration" 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_tag_configuration" end # resource path local_var_path = '/api/v2/metrics/{metric_name}/tags'.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] || 'MetricTagConfigurationResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] new_options = opts.merge( :operation => :update_tag_configuration, :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 => "V2" ) data, status_code, headers = @api_client.call_api(Net::HTTP::Patch, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: MetricsAPI#update_tag_configuration\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end