class Azure::Monitor::Mgmt::V2017_05_01_preview::Metrics
Monitor
Management Client
Attributes
@return [MonitorManagementClient] reference to the MonitorManagementClient
Public Class Methods
Creates and initializes a new instance of the Metrics
class. @param client service class for accessing basic functionality.
# File lib/2017-05-01-preview/generated/azure_mgmt_monitor/metrics.rb, line 17 def initialize(client) @client = client end
Public Instance Methods
**Lists the metric values for a resource**.
@param resource_uri [String] The identifier of the resource. @param timespan [String] The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. @param interval [Duration] The interval (i.e. timegrain) of the query. @param metric [String] The name of the metric to retrieve. @param aggregation [String] The list of aggregation types (comma separated) to retrieve. @param top [Float] The maximum number of records to retrieve. Valid only if $filter is specified. Defaults to 10. @param orderby [String] The aggregation to use for sorting results and the direction of the sort. Only one order can be specified. Examples: sum asc. @param filter [String] The **$filter** is used to reduce the set of metric data returned.
Example:
Metric contains metadata A, B and C.
- Return all time series of C where A = a1 and B = b1 or b2
**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**
- Invalid variant:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**
This is invalid because the logical or operator cannot separate two different metadata names.
- Return all time series where A = a1, B = b1 and C = c1:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**
- Return all time series where A = a1
**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. @param result_type [ResultType] Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's description for details. Possible values include: 'Data', 'Metadata' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.
@return [Response] operation results.
# File lib/2017-05-01-preview/generated/azure_mgmt_monitor/metrics.rb, line 59 def list(resource_uri, timespan:nil, interval:nil, metric:nil, aggregation:nil, top:nil, orderby:nil, filter:nil, result_type:nil, custom_headers:nil) response = list_async(resource_uri, timespan:timespan, interval:interval, metric:metric, aggregation:aggregation, top:top, orderby:orderby, filter:filter, result_type:result_type, custom_headers:custom_headers).value! response.body unless response.nil? end
**Lists the metric values for a resource**.
@param resource_uri [String] The identifier of the resource. @param timespan [String] The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. @param interval [Duration] The interval (i.e. timegrain) of the query. @param metric [String] The name of the metric to retrieve. @param aggregation [String] The list of aggregation types (comma separated) to retrieve. @param top [Float] The maximum number of records to retrieve. Valid only if $filter is specified. Defaults to 10. @param orderby [String] The aggregation to use for sorting results and the direction of the sort. Only one order can be specified. Examples: sum asc. @param filter [String] The **$filter** is used to reduce the set of metric data returned.
Example:
Metric contains metadata A, B and C.
- Return all time series of C where A = a1 and B = b1 or b2
**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**
- Invalid variant:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**
This is invalid because the logical or operator cannot separate two different metadata names.
- Return all time series where A = a1, B = b1 and C = c1:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**
- Return all time series where A = a1
**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. @param result_type [ResultType] Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's description for details. Possible values include: 'Data', 'Metadata' @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.
@return [Concurrent::Promise] Promise object which holds the HTTP response.
# File lib/2017-05-01-preview/generated/azure_mgmt_monitor/metrics.rb, line 138 def list_async(resource_uri, timespan:nil, interval:nil, metric:nil, aggregation:nil, top:nil, orderby:nil, filter:nil, result_type:nil, custom_headers:nil) fail ArgumentError, 'resource_uri is nil' if resource_uri.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = '{resourceUri}/providers/microsoft.insights/metrics' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], skip_encoding_path_params: {'resourceUri' => resource_uri}, query_params: {'timespan' => timespan,'interval' => interval,'metric' => metric,'aggregation' => aggregation,'$top' => top,'$orderby' => orderby,'$filter' => filter,'resultType' => result_type,'api-version' => @client.api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:get, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRest::HttpOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::Monitor::Mgmt::V2017_05_01_preview::Models::Response.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end
**Lists the metric values for a resource**.
@param resource_uri [String] The identifier of the resource. @param timespan [String] The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. @param interval [Duration] The interval (i.e. timegrain) of the query. @param metric [String] The name of the metric to retrieve. @param aggregation [String] The list of aggregation types (comma separated) to retrieve. @param top [Float] The maximum number of records to retrieve. Valid only if $filter is specified. Defaults to 10. @param orderby [String] The aggregation to use for sorting results and the direction of the sort. Only one order can be specified. Examples: sum asc. @param filter [String] The **$filter** is used to reduce the set of metric data returned.
Example:
Metric contains metadata A, B and C.
- Return all time series of C where A = a1 and B = b1 or b2
**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**
- Invalid variant:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**
This is invalid because the logical or operator cannot separate two different metadata names.
- Return all time series where A = a1, B = b1 and C = c1:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**
- Return all time series where A = a1
**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. @param result_type [ResultType] Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's description for details. Possible values include: 'Data', 'Metadata' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.
@return [MsRestAzure::AzureOperationResponse] HTTP response information.
# File lib/2017-05-01-preview/generated/azure_mgmt_monitor/metrics.rb, line 99 def list_with_http_info(resource_uri, timespan:nil, interval:nil, metric:nil, aggregation:nil, top:nil, orderby:nil, filter:nil, result_type:nil, custom_headers:nil) list_async(resource_uri, timespan:timespan, interval:interval, metric:metric, aggregation:aggregation, top:top, orderby:orderby, filter:filter, result_type:result_type, custom_headers:custom_headers).value! end