Hello Folks,
input {
http_poller {
urls => {
test2 => {
method => get
url => "http://www.coincap.io/history/1day/XRP"
}
}
request_timeout => 60
schedule => { cron => "* * * * * * UTC"}
codec => "json"
}
}
output {
stdout {
codec => rubydebug
}
}
I am fetching a JSON data from the above API. The logstash rubydebug output of that JSON is as below:
{
"preminedSig" => false,
"isBuy" => true,
"dom" => 39,
"altCap" => 69121887494,
"explorerURL" => "https://blockexplorer.com/",
"btcCap" => 44395178760,
"vwapDataBTC" => "2682.6451919194055",
"capPercent" => "5.70",
"supply" => "16389000",
"long" => "Bitcoin",
"cap24hrChangePercent" => "5.70",
"twitter" => "",
"perc" => "5.70",
"market_cap" => [
[ 0] [
[0] 1367174841000,
[1] 1500517590
],
[ 1] [
[0] 1367261101000,
[1] 1575032004
],
],
"@timestamp" => 2017-06-13T20:02:21.397Z,
"price" => [
[ 0] [
[0] 1497286765000,
[1] 0.255964
],
[ 1] [
[0] 1497287042000,
[1] 0.255944
],
[ 2] [
[0] 1497287359000,
[1] 0.253767
]
}
In the above JSON output , i need to parse out the price field which contains two values ([0] , [1] ). One is Timestamp and the other is price. i need to fetch it out those two fields and set the type for one field as TimeStamp and other as number and send to Elastic Search.
I have tried using Mutate and Grok filter. I am unable to attain the result.
Can anyone of guys help me out ?
[ 1] [
[0] 1497287042000, ------- Give a seperate field name for this as timestamp
[1] 0.255944 -- give a seperate field name for this as price.
],