lib/fluent/plugin/in_azuremonitormetrics.rb in fluent-plugin-azuremonitormetrics-0.0.3 vs lib/fluent/plugin/in_azuremonitormetrics.rb in fluent-plugin-azuremonitormetrics-0.0.4

- old
+ new

@@ -23,15 +23,14 @@ config_param :timespan, :integer, :default => 300 config_param :interval, :string, :default => "PT1M" config_param :resource_uri, :string, :default => nil config_param :aggregation, :string, :default => nil config_param :top, :integer, :default => nil - config_param :orderby, :string, :default => nil config_param :filter, :string, :default => nil config_param :result_type, :string, :default => nil config_param :metrics, :string, :default => nil - config_param :api_version, :string, :default => "2016-09-01" + config_param :api_version, :string, :default => "2017-05-01-preview" def initialize super end @@ -75,23 +74,24 @@ # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? - metrics_string = get_param_string(@metrics, "name.value") - aggregation_string = @aggregation.empty? ? '' : get_param_string(@aggregation, "aggregationType") + timespanstring = "#{start_time.utc.iso8601}/#{end_time.utc.iso8601}" + top = @filter.nil? ? nil : @top - filter = "timeGrain eq duration'#{@interval}' #{metrics_string} #{aggregation_string} and startTime eq #{start_time.utc.iso8601} and endTime eq #{end_time.utc.iso8601}" - log.debug filter { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceUri' => @resource_uri}, query_params: {'api-version' => @api_version, - '$top' => @top, - '$orderby' => @orderby, - '$filter' => filter, - 'resultType' => @result_type}, + '$top' => top, + '$filter' => @filter, + 'timespan' => timespanstring, + 'interval' => @interval, + 'metric' => @metrics, + 'resultType' => @result_type, + 'aggregation'=> @aggregation}, headers: request_headers.merge(custom_headers || {}), base_url: @client.base_url } end @@ -128,19 +128,21 @@ http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) - log.error(error_model['error']['message']) + log.error("Error occurred while sending the request") + log.error(error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? # Deserialize Response if status_code == 200 begin result.body = response_content.to_s.empty? ? nil : JSON.load(response_content) rescue Exception => e log.error("Error occurred in parsing the response") + log.error(e) end end result end