I want to convert currency (to indian rupees) from USD or EUR.
I am using the following code in Ruby
if [Currency] == "EUR" or [Currency] == "USD" {
ruby {
id => "addingCurrencyValue"
code =>
'
event.set("[currencyMultiple]", 80) if event.get("[Currency]") == "EUR"
event.set("[currencyMultiple]", 70) if event.get("[Currency]") == "USD"
'
}
}
if [currencyMultiple] {
ruby {
id => "currencyConverter"
code =>
'
event.set("[currencyConvertedValue]", (event.get("[Unit_Sold_Value]")*event.get("[currencyMultiple]")))
event.set("[Value]", event.get("[currencyConvertedValue]"))
'
}
}
}
The response in STDOUT is very weird and I cannot find any reference.
{
"@timestamp" => 2018-12-06T16:17:50.911Z,
"message" => "Currency,Unit_Sold_Value\r\n",
"@version" => "1",
"Currency" => "Currency",
"Unit_Sold_Value" => "Unit_Sold_Value"
}
{
"Value" => "100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100",
"@version" => "1",
"Currency" => "EUR",
"currencyConvertedValue" => "100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100100",
"@timestamp" => 2018-12-06T16:17:50.946Z,
"message" => "EUR,100",
"currencyMultiple" => 80,
"Unit_Sold_Value" => "100"
}
{
"Value" => "10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010",
"@version" => "1",
"Currency" => "USD",
"currencyConvertedValue" => "10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010",
"@timestamp" => 2018-12-06T16:17:50.946Z,
"message" => "USD,10\r\n",
"currencyMultiple" => 70,
"Unit_Sold_Value" => "10"
My csv file only has two rows and columns:
Currency: EUR (or USD)
Unti_Sold_value: 100 (or 10)