lib/scaltainer/newrelic/metrics.rb
def get_avg_response_time(app_id, from, to)
      url = "#{@base_url}/applications/#{app_id}/metrics/data.json"
      conn = Excon.new(url, persistent: true, tcp_nodelay: true)
      time_range = "from=#{from.iso8601}&to=#{to.iso8601}"
      metric_names_array = %w(
        names[]=HttpDispatcher&values[]=average_call_time&values[]=call_count
        names[]=WebFrontend/QueueTime&values[]=call_count&values[]=average_response_time
      )
      response_array = request(conn, metric_names_array, time_range)
      http_call_count, http_average_call_time = response_array[0]["call_count"], response_array[0]["average_call_time"]
      webfe_call_count, webfe_average_response_time = response_array[1]["call_count"], response_array[1]["average_response_time"]

      http_average_call_time + (1.0 * webfe_call_count * webfe_average_response_time / http_call_count) rescue 0.0/0
    end
def get_avg_response_time(app_id, from, to)
      url = "#{@base_url}/applications/#{app_id}/metrics/data.json"
      conn = Excon.new(url, persistent: true, tcp_nodelay: true)
      time_range = "from=#{from.iso8601}&to=#{to.iso8601}"
      metric_names_array = %w(
        names[]=HttpDispatcher&values[]=average_call_time&values[]=call_count
        names[]=WebFrontend/QueueTime&values[]=call_count&values[]=average_response_time
      )
      response_array = request(conn, metric_names_array, time_range)
      http_call_count, http_average_call_time = response_array[0]["call_count"], response_array[0]["average_call_time"]
      webfe_call_count, webfe_average_response_time = response_array[1]["call_count"], response_array[1]["average_response_time"]

      http_average_call_time + (1.0 * webfe_call_count * webfe_average_response_time / http_call_count) rescue 0.0/0
    end
def get_avg_response_time ( app_id , from , to ) url = "#{@base_url}/applications/#{app_id}/metrics/data.json" conn = Excon . new ( url , persistent : true , tcp_nodelay : true ) time_range = "from=#{from.iso8601}&to=#{to.iso8601}" metric_names_array = %w( names[]=HttpDispatcher&values[]=average_call_time&values[]=call_count names[]=WebFrontend/QueueTime&values[]=call_count&values[]=average_response_time ) response_array = request ( conn , metric_names_array , time_range ) http_call_count , http_average_call_time = response_array [ 0 ] [ "call_count" ] , response_array [ 0 ] [ "average_call_time" ] webfe_call_count , webfe_average_response_time = response_array [ 1 ] [ "call_count" ] , response_array [ 1 ] [ "average_response_time" ] http_average_call_time + ( 1.0 * webfe_call_count * webfe_average_response_time / http_call_count ) rescue 0.0 / 0 end
https://docs.newrelic.com/docs/apis/rest-api-v2/application-examples-v2/average-response-time-examples-v2
https : // docs . newrelic . com / docs / apis / rest - api - v2 / application - examples - v2 / average - response - time - examples - v2