Key>' MACKEREL_SERVICE_NAME = '<service name>' yahoo_client = YahooFinance::Client.new data = yahoo_client.quote('USDJPY=X', [:ask, :bid, :last_trade_date, :last_trade_time]) time = Time.strptime("#{data.last_trade_date} #{data.last_trade_time} +01:00", '%m/%d/ %Y %H:%M%P %:z') mackerel_client = Mackerel::Client.new(mackerel_api_key: MACKEREL_API_KEY) mackerel_client.post_service_metrics(MACKEREL_SERVICE_NAME, [ { name: 'finance.usdjpy.ask', time: time.to_i, value: data.ask.to_f }, { name: 'finance.usdjpy.bid', time: time.to_i, value: data.bid.to_f } ])