Hi,
I have above output coming from one API and I need to pass this to another API where URL will have variable componets of datasource array and nodeID. And I need to store this data an ingest it to elastic as documents. Could you please help me with ruby code how I can achieve in logstash.
{
"@timestamp" => 2022-06-17T13:18:26.431584Z,
"nodeId" => "18",
"datasource" => [
[0] "ssh",
[1] "icmp"
]
}
{
"@timestamp" => 2022-06-17T13:18:26.431584Z,
"nodeId" => "13"
}
{
"@timestamp" => 2022-06-17T13:18:26.431584Z,
"nodeId" => "14"
}
{
"@timestamp" => 2022-06-17T13:18:26.431584Z,
"nodeId" => "8",
"datasource" => [
[ 0] "ciscoMemoryPoolFree",
[ 1] "ciscoSupyState",
[ 2] "bufferNoMem",
[ 3] "CiscoEnvMonState",
[ 4] "tcpAttemptFails",
[ 5] "ciscoMemoryPoolMax",
[ 6] "ciscoSupSource",
[ 7] "avgBusy5",
[ 8] "tcpPassiveOpens",
[ 9] "ciscoMemoryPoolUsed",
[10] "tcpOutSegs",
......
]
}
{
"@timestamp" => 2022-06-17T13:18:26.431584Z,
"nodeId" => "10",
"datasource" => [
[0] "icmp"
]
}
{
"@timestamp" => 2022-06-17T13:18:26.431584Z,
"nodeId" => "1",
"datasource" => [
[0] "hrSystemUptime"
]
}
My ruby code:
#ruby {
# init => "
# require 'net/http'
# require 'uri'
# require 'json'
# "
# code => "
event.get('nodeId')
# event.get('datasource').each { |i|
# uri = URI.parse('xxxxxxxxxx/rest/measurements/node%5B%{nodeId}%5D.nodeSnmp%5B%5D/%{#datasource[i]}?start=-7200000')
# request = Net::HTTP::Get.new(uri)
#}
#"
#}
#}