0

Elasticsearchから返された結果から値を抽出しようとしています。返される結果セットは配列であり、配列内のオブジェクトはHashie:Mashです。

結果セットは次のようになります。

#<Hashie::Mash @fields=#<Hashie::Mash latency=[8.0] response_code=[200.0] response_time=[744.0] sampler_label=["globalnav"] success=[1] my_id=["specnn1"]> @message="globalnav,1,744,200,8,specnn1,\r" @source="file:///fqdn/ffw_spectrum.log" @source_host="xplda04.ieee.org" @source_path="/full/path/ffw_spectrum.log" @tags=["jm_type"] @timestamp="2013-02-04T20:47:12.472Z" @type="jm_type" _id="5ACJI7NqRvCK_THBiRszrQ">
#<Hashie::Mash @fields=#<Hashie::Mash latency=[8.0] response_code=[200.0] response_time=[801.0] sampler_label=["globalnav"] success=[1] my_id=["specnn1"]> @message="globalnav,1,801,200,8,specnn1,\r" @source="file:///fqdn/ffw_spectrum.log" @source_host="xplda04.ieee.org" @source_path="/full/path/ffw_spectrum.log" @tags=["jm_type"] @timestamp="2013-02-04T20:47:12.489Z" @type="jm_type" _id="Mzpz30H3Qf6wLxx_IAO8uQ">
#<Hashie::Mash @fields=#<Hashie::Mash latency=[8.0] response_code=[200.0] response_time=[10.0] sampler_label=["homepage"] success=[1] my_id=["specnn1"]> @message="homepage,1,10,200,8,specnn1,\r" @source="file:///fqdn/ffw_spectrum.log" @source_host="xplda04.ieee.org" @source_path="/full/path/ffw_spectrum.log" @tags=["jm_type"] @timestamp="2013-02-04T20:47:28.115Z" @type="jm_type" _id="vN8t39UmQwy9PxhRGKU5uQ">
#<Hashie::Mash @fields=#<Hashie::Mash latency=[8.0] response_code=[200.0] response_time=[9.0] sampler_label=["homepage"] success=[1] my_id=["specnn1"]> @message="homepage,1,9,200,8,specnn1,\r" @source="file:///fqdn/ffw_spectrum.log" @source_host="xplda04.ieee.org" @source_path="/full/path/ffw_spectrum.log" @tags=["jm_type"] @timestamp="2013-02-04T20:47:28.196Z" @type="jm_type" _id="mMkV4sqwTEqU6OiY5-q3JA">
#<Hashie::Mash @fields=#<Hashie::Mash latency=[10.0] response_code=[200.0] response_time=[747.0] sampler_label=["globalnav"] success=[1] my_id=["specnn1"]> @message="globalnav,1,747,200,10,specnn1,\r" @source="file:///fqdn/ffw_spectrum.log" @source_host="xplda04.ieee.org" @source_path="/full/path/ffw_spectrum.log" @tags=["jm_type"] @timestamp="2013-02-04T20:47:12.475Z" @type="jm_type" _id="LVZaHrExS7Cy8l9ndCBGIA">
#<Hashie::Mash @fields=#<Hashie::Mash latency=[17.0] response_code=[200.0] response_time=[25.0] sampler_label=["random_content"] success=[1] my_id=["specnn1"]> @message="random_content,1,25,200,17,specnn1,\r" @source="file:///fqdn/ffw_spectrum.log" @source_host="xplda04.ieee.org" @source_path="/full/path/ffw_spectrum.log" @tags=["jm_type"] @timestamp="2013-02-04T20:47:28.185Z" @type="jm_type" _id="cLaYGsA_T9e2F70NbvoSqQ">
#<Hashie::Mash @fields=#<Hashie::Mash latency=[800.0] response_code=[200.0] response_time=[808.0] sampler_label=["random_content"] success=[1] my_id=["specnn1"]> @message="random_content,1,808,200,800,specnn1,\r" @source="file:///fqdn/ffw_spectrum.log" @source_host="xplda04.ieee.org" @source_path="/full/path/ffw_spectrum.log" @tags=["jm_type"] @timestamp="2013-02-04T20:47:12.465Z" @type="jm_type" _id="OFbQcHyATDS2l-IWxltIug">
#<Hashie::Mash @fields=#<Hashie::Mash latency=[15.0] response_code=[200.0] response_time=[20.0] sampler_label=["homepage"] success=[1] my_id=["specnn1"]> @message="homepage,1,20,200,15,specnn1,\r" @source="file:///fqdn/ffw_spectrum.log" @source_host="xplda04.ieee.org" @source_path="/full/path/ffw_spectrum.log" @tags=["jm_type"] @timestamp="2013-02-04T20:47:12.467Z" @type="jm_type" _id="gdz3yDkTSyqgn-2S5yirEg">
#<Hashie::Mash @fields=#<Hashie::Mash latency=[393.0] response_code=[200.0] response_time=[400.0] sampler_label=["random_content"] success=[1] my_id=["specnn1"]> @message="random_content,1,400,200,393,specnn1,\r" @source="file:///fqdn/ffw_spectrum.log" @source_host="xplda04.ieee.org" @source_path="/full/path/ffw_spectrum.log" @tags=["jm_type"] @timestamp="2013-02-04T20:47:12.491Z" @type="jm_type" _id="5XGEVQzFS_S_OTLpD1KPfQ">
#<Hashie::Mash @fields=#<Hashie::Mash latency=[16.0] response_code=[200.0] response_time=[22.0] sampler_label=["random_content"] success=[1] my_id=["specnn1"]> @message="random_content,1,22,200,16,specnn1,\r" @source="file:///fqdn/ffw_spectrum.log" @source_host="xplda04.ieee.org" @source_path="/full/path/ffw_spectrum.log" @tags=["jm_type"] @timestamp="2013-02-04T20:47:12.504Z" @type="jm_type" _id="wi14pyNHRWaH6AK7874KiA">

配列をループし、次にhasieをループし、配列をループして、hashie mash内の値に到達することで、response_timeを抽出できます。

response_timeルビーを使用して値を抽出する簡単または効率的な方法はありますか?

4

1 に答える 1

0

あなたarray.map(&:response_time)が達成したいことをしていますか?

于 2013-02-06T22:42:31.813 に答える